0

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/");
Isaac Waller
  • 32,709
  • 29
  • 96
  • 107
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697

3 Answers3

3

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.

Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
SolutionYogi
  • 31,807
  • 12
  • 70
  • 78
2

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;
}
Gumbo
  • 643,351
  • 109
  • 780
  • 844
  • It looks promising. How did you get it working? I tried: http://code.google.com/apis/ajax/playground/, Google Gadget editor and even the navbar in my browser. Anything does not happen. – Léo Léopold Hertz 준영 Jul 01 '09 at 19:49
0

Like this?

searchUrl += escape(query);
thenewwindow=window.open(searchUrl,'Google','height=600,width=450');
return false;
redwall_hp
  • 1,067
  • 2
  • 10
  • 18