如何在 Google 小工具中打开新窗口?

发布于 2024-07-26 18:50:27 字数 320 浏览 8 评论 0原文

它既不打开选项卡,也不打开窗口:Google 小工具的代码 此处. 如果您知道 HTML 中的 'target="_blank"',我正在为 Google Gadgets 寻找类似的工具。 更准确地说,我不明白为什么 JavaScript 部分不起作用:

window.open("http://www.google.com/");

It opens neither a tab nor a window: the code for a Google Gadget here. If you know 'target="_blank"' from HTML, I am looking for a similar tool for Google Gadgets. More precisely, I cannot understand why the JavaScript piece does not work:

window.open("http://www.google.com/");

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

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

发布评论

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

评论(3

冰魂雪魄 2024-08-02 18:50:27

好吧,如果您想打开新窗口,请明确执行。

var query = "bijection";
var searchUrl = "http://www.google.com/search?q=";

if (query != "" && searchUrl != "") {
    searchUrl += escape(query);
    window.open(searchUrl); //You can pass additional parameters, look for window.open examples on the Internet.
    return false;
}

target 属性用于 link 元素 (),它指示浏览器在用户单击该 URL 时在新窗口中打开该 URL。

Well, if you want to open the new window, do it explicitly.

var query = "bijection";
var searchUrl = "http://www.google.com/search?q=";

if (query != "" && searchUrl != "") {
    searchUrl += escape(query);
    window.open(searchUrl); //You can pass additional parameters, look for window.open examples on the Internet.
    return false;
}

The target attribute is for link element () which instructs browser to open the URL in new window if user clicks on it.

小梨窩很甜 2024-08-02 18:50:27

使用该目标打开一个新窗口,而不是替换当前窗口的 URL:

var query = "bijection";
var searchUrl = "http://www.google.com/search?q=";
if (query != "" && searchUrl != "") {
    searchUrl += escape(query);
    var newWindow = window.open(searchUrl, '_blank');
    return false;
}

Open a new window with that target instead of replacing the current’s window URL:

var query = "bijection";
var searchUrl = "http://www.google.com/search?q=";
if (query != "" && searchUrl != "") {
    searchUrl += escape(query);
    var newWindow = window.open(searchUrl, '_blank');
    return false;
}
夏尔 2024-08-02 18:50:27

像这样?

searchUrl += escape(query);
thenewwindow=window.open(searchUrl,'Google','height=600,width=450');
return false;

Like this?

searchUrl += escape(query);
thenewwindow=window.open(searchUrl,'Google','height=600,width=450');
return false;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文