...

View Full Version : window.open Search using QUOTES ??



ghoulardi
06-17-2004, 12:02 PM
javascript:void(window.open("http://www.google.com/search?hl=en&ie=UTF-8&q=%sl&btnG=Google+Search"));

This Opens a new window and searches Google but my problem is I cant include QUOTES. (e.g. "1 2 3")

%s = the searched word.

Does anyone know how I can make this work? Im a novice and Im totaly lost. I was up half the night tring to figure it out. Thanks ;)

glenngv
06-17-2004, 02:05 PM
window.open("http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q="+escape('"%s"'))

ghoulardi
06-17-2004, 11:36 PM
Hey Glen, Thanks. That works good for only using quoyes but is there a way to have it so I can use quotes or not use them?

So the searched term will not allways be in quotes, only if searcher enters them with the search?

Thanks for your help!!!

glenngv
06-18-2004, 03:32 AM
like this?

window.open("http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q="+escape(document.theForm.theField.value))

ghoulardi
06-18-2004, 04:04 AM
Where do I enter the search term?
This script is actualy for a toolbar, and the %s is the search area read by the toolbar.

WHat do you think?

Thanks again!!

glenngv
06-18-2004, 04:24 AM
I don't know how that %s works.
Try:

window.open("http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q="+escape(%s))

ghoulardi
06-18-2004, 04:55 AM
It is for a toolbar I am working on.
It installs a reg file with all the search urls

The %s is just what the toolbar uses for the search field.
The URLs look like this in the reg

http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q=%s

So when I enter a search in the toolbar (e.g. cow)

It will change the %s to cow


http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q=cow

but the search opens in the same window. :(

The one you gave me works perfect ...

javascript:window.open("http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q="+escape('"%s"'))

except the quotes are permanently in the search.

The last two you gave did not do anything when I enterd them in IE.

Thanks

glenngv
06-18-2004, 05:25 AM
The toolbar should replace all occurrences of " and ' in the entered search term with \" and \' so that you can insert it successfully in javascript either using a single quote or double quote as string delimiter.

javascript:window.open("http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q="+escape("%s"))

or

javascript:window.open("http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q="+escape('%s'))

So when the search term is "O'Reilly", the javascript code will look like:

javascript:window.open("http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q="+escape('\"O\'Reilly\"'))


Is that possible?

ghoulardi
06-18-2004, 05:45 AM
Holy cow man! You did it!!!

Sheeew weeee!
Like I said I dont really know much about javascript but I learned some in the past couple days.

Thanks for sticking in there man, I really appreciate it.

This is the one that works
javascript:window.open("http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q="+escape('%s'))

I added void because it would change the original page.

javascript:void(window.open("http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q="+escape('%s')))

You deserve a pat on the back!! Thanks again, and best of luck to you.

glenngv
06-18-2004, 06:03 AM
That will fail if the search word contains single quote. That's the point of my previous post.

ghoulardi
06-18-2004, 06:24 AM
I ran into another problem. Well to me it is anyways. :confused:


javascript:void(window.open("http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q="+escape('%s')))


What if the %s is not at the end of the URL like this one, it is in the middle.


http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=%s&btnI=I%%27m+Feeling+Lucky

can you show me how it should look, since alot of the engines I'll be using are like that.

:eek:
The toolbar has around 500 search engines to choose from, to customize it.

ghoulardi
06-18-2004, 06:42 AM
I just read you previous post.
No I dont think it will replace them, Ill have to check it out

glenngv
06-21-2004, 03:30 AM
I ran into another problem. Well to me it is anyways. :confused:


javascript:void(window.open("http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q="+escape('%s')))


What if the %s is not at the end of the URL like this one, it is in the middle.


http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=%s&btnI=I%%27m+Feeling+Lucky

can you show me how it should look, since alot of the engines I'll be using are like that.

:eek:
The toolbar has around 500 search engines to choose from, to customize it.
I don't see any problem with that. I just put the "q" parameter at the end for readability's sake. The position of any url parameter doesn't matter as long as you use "?" in the first parameter and then "&" in the succeeding parameters.



I just read you previous post.
No I dont think it will replace them, Ill have to check it out

Sorry, you probably misinterpreted my previous post.
What I was asking you was, if it's possible that you can tell the toolbar you're working on (by way of a script or something) to replace all occurrences of " and ' by \" and \' in such a way that when the user types "O'Reilly" as the search keyword, %s will become \"O\'Reilly\"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum