Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Javascript Google serarch in a new window ...

Apr 27, 2005 1:07PM PDT

Here's my code:

javascript: x=escape(getSelection());if(!x)%7Bvoid(x=prompt('Google%20search%20for%20...',''))%7D;if(x!=null)%7Bwindow.location='http://www.google.com/search?client=googlet&q='+x%7D

What it does is this:

If I have text highlighted in my browser window when I run this script, it will search Google for what I have highlighted. If no text is highlighted, then prompts me with a text box to input what I want to search Google for.

What I want it to do:

I want it to do everything that it already does, but open the results in a new window. Is that even possible? I use Safari as my browser.

Discussion is locked