在新浏览器中打开链接吗?
我在 javascript 文件中有以下代码,并且需要在新窗口中打开正在生成的链接。
if (currentSearchType === 'extSearch') {
extSearchSearchValue = extSearchSearchInput.val();
window.location.href = replaceByObject(global.uhg.data['general'].body.extSearchSearchUrl, {
q: extSearchSearchValue
});
通常,对于 javascript,我相信您会使用 window.open 类型的函数,但不确定如何将其与此类代码合并。
I have the following code below in a javascript file and need to have the link that is being generated open in a new window.
if (currentSearchType === 'extSearch') {
extSearchSearchValue = extSearchSearchInput.val();
window.location.href = replaceByObject(global.uhg.data['general'].body.extSearchSearchUrl, {
q: extSearchSearchValue
});
Normally with javascript I believe you'd use a window.open type of function, but not sure how to incorporate that with this type of code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不管你怎么做,用 javascript 打开一个新的浏览器窗口很可能会被弹出窗口拦截器阻止,所以也许你应该重新考虑用户自己单击常规链接的方法,然后你可以使用 target="..."。
However you do it, opening a new browser window with javascript will most probably be blocked by popup blockers, so perhaps you should rethink your approach to the user himself clicking a regular link, then you can use target="...".
只需使用 var 保存 URL,然后将其传递给
window.open()
...Just use a var to hold the URL and then pass it to
window.open()
...