Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    window.open Search using QUOTES ??

    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

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,961
    Thanks
    0
    Thanked 236 Times in 233 Posts
    window.open("http://www.google.com/search?hl=en&ie=UTF-8&btnG=Google+Search&q="+escape('"%s"'))

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!!!

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,961
    Thanks
    0
    Thanked 236 Times in 233 Posts
    like this?

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

  • #5
    New Coder
    Join Date
    Mar 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!!

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,961
    Thanks
    0
    Thanked 236 Times in 233 Posts

    I thought it's in a normal form

    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))

  • #7
    New Coder
    Join Date
    Mar 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Code:
    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

    Code:
    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
    Last edited by ghoulardi; 06-18-2004 at 08:02 AM.

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,961
    Thanks
    0
    Thanked 236 Times in 233 Posts
    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?

  • #9
    New Coder
    Join Date
    Mar 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,961
    Thanks
    0
    Thanked 236 Times in 233 Posts
    That will fail if the search word contains single quote. That's the point of my previous post.

  • #11
    New Coder
    Join Date
    Mar 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I ran into another problem. Well to me it is anyways.


    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.

    Code:
    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.


    The toolbar has around 500 search engines to choose from, to customize it.
    Last edited by ghoulardi; 06-18-2004 at 06:35 AM.

  • #12
    New Coder
    Join Date
    Mar 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just read you previous post.
    No I dont think it will replace them, Ill have to check it out

  • #13
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,961
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Quote Originally Posted by ghoulardi
    I ran into another problem. Well to me it is anyways.


    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.

    Code:
    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.


    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\"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •