Search code examples
javascriptgoogle-gadgetigoogle

How to open a new window in Google Gadget?


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/");

Solution

  • 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.