如何在新窗口中打开 JavaScript 搜索引擎(使用“function Jump() {”)?

发布于 2024-08-15 14:31:06 字数 200 浏览 3 评论 0原文

看到这个 http://javascript.internet.com/forms/multiple-search-引擎.html 。我想知道如何在新窗口中打开搜索结果。帮我!

see this http://javascript.internet.com/forms/multiple-search-engine.html . i wonder how to open the search result in new window. help me!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回眸一遍 2024-08-22 14:31:06

1) 不要这样做

2) 真的不要这样做

3) 如果您必须这样做,请将函数绑定到“搜索”按钮的 onclick 事件。在函数内部,使用 window.open 弹出一个新窗口以及您想要将用户发送到的地址。根据用户配置浏览器的方式,浏览器可能会打开另一个选项卡。函数结束时,返回 false。


好吧,实际上不需要编写任何其他代码,因为表单已经是 JS 驱动的。在您链接到的该页面的源代码中,找到以下行:

location.href = finalSearchString; 

将其替换为以下行:

window.open(finalSearchString, 'Search results');

就是这样。该按钮将弹出另一个页面或选项卡。

警告

该页面有些过时,某些搜索引擎无法正常工作(生成的链接是错误的)。

1) Don't do that

2) Really don't do that

3) In the case that you have to do that, bind a function to the onclick event of the "search" button. Inside the function, use window.open to pop up a new window with the address you want to send the user to. Depending on how the user configured his browser, the browser may instead open another tab. At the end of the function, return false.


OK actually there's no need to write any other code because the form is already JS-driven. In the source of that page you linked to, find the following line:

location.href = finalSearchString; 

Substitute it with the following line:

window.open(finalSearchString, 'Search results');

That's it. The button will pop up another page or tab.

WARNING

That page is somewhat outdated and some of the search engines don't work properly (the link generated is wrong).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文