Welcome to TalkGraphics.com
Results 1 to 10 of 10

Thread: Site search box

  1. #1

    Default Site search box

    I have read posts from September 2014 explaining how to add a site search box but when I test it, my search results are not limited to my site. I copied the placeholder body code and head code given and edited it for my site as follows:

    <script type="text/javascript">
    //Enter domain of site to search.
    var domain="www.wonershhistory.co.uk" //replace this with your site domain

    function GoogleSiteSearch(cur){
    cur.q.value="site:"+domain+" "+cur.searchTerm.value
    }
    </script>

    <form action="http://www.google.com/search" method="get" target="_blank" onSubmit="GoogleSiteSearch(this)">
    <p>Search www.wonershhistory.co.uk:<br /> <!--replace [[...]] with your details -->
    <input id="searchBox" name="searchTerm" type="text" style="width: 200px" />*<input type="submit" value="Search" /></p>
    <input name="q" type="hidden" />

    I think the problem might be in the third line from the end. I have tried including one set/two sets of [] brackets and also quotes "".

    I would be grateful if someone could show me where I have gone wrong.

  2. #2
    Join Date
    Aug 2000
    Location
    Placitas, New Mexico, USA
    Posts
    41,502

    Default Re: Site search box

    Acorn can do this when he checks this post.

  3. #3
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,814

    Info Re: Site search box

    Quote Originally Posted by JFry View Post
    I have read posts from September 2014 explaining how to add a site search box but when I test it, my search results are not limited to my site. I copied the placeholder body code and head code given and edited it for my site as follows:

    <script type="text/javascript">
    //Enter domain of site to search.
    var domain="www.wonershhistory.co.uk" //replace this with your site domain

    function GoogleSiteSearch(cur){
    cur.q.value="site:"+domain+" "+cur.searchTerm.value
    }
    </script>

    <form action="http://www.google.com/search" method="get" target="_blank" onSubmit="GoogleSiteSearch(this)">
    <p>Search www.wonershhistory.co.uk:<br /> <!--replace [[...]] with your details -->
    <input id="searchBox" name="searchTerm" type="text" style="width: 200px" />*<input type="submit" value="Search" /></p>
    <input name="q" type="hidden" />

    I think the problem might be in the third line from the end. I have tried including one set/two sets of [] brackets and also quotes "".

    I would be grateful if someone could show me where I have gone wrong.
    You were close. The bit in red is a comment so anything in there is ignored so forget it.

    The problem was in the head part. It iworks when the slash separates the site from the search term. Use

    Code:
    <script>
    //Enter domain of site to search.
    var domain="www.wonershhistory.co.uk" //replace this with your site domain
    
    
    function GoogleSiteSearch(cur){
    cur.q.value="site:"+domain+"/ "+cur.searchTerm.value
    }
    </script>
    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  4. #4
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,814

    Info Re: Site search box

    I prefer DuckDuckGo as it does not track any search.

    Try this:

    Code:
    <iframe src="https://duckduckgo.com/search.html?width=650&kn=1&duck=yes&site=www.wonershhistory.co.uk&prefill=Search www.wonershhistory.co.uk&bgcolor=#003100&focus=yes&kn = 1 " style="overflow:hidden;margin:0;padding:0;width:783px;height:60px;" frameborder="0"></iframe>
    You can modify the search values from this page: https://duckduckgo.com/search_box. Original Post is here: https://www.talkgraphics.com/showthr...434#post570434.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  5. #5

    Default Re: Site search box

    Quote Originally Posted by Acorn View Post
    I prefer DuckDuckGo as it does not track any search.

    Try this:

    Code:
    <iframe src="https://duckduckgo.com/search.html?width=650&kn=1&duck=yes&site=www.wonershhistory.co.uk&prefill=Search www.wonershhistory.co.uk&bgcolor=#003100&focus=yes&kn = 1 " style="overflow:hidden;margin:0;padding:0;width:783px;height:60px;" frameborder="0"></iframe>
    You can modify the search values from this page: https://duckduckgo.com/search_box. Original Post is here: https://www.talkgraphics.com/showthr...434#post570434.

    Acorn
    Thank you. I will give both a go and see what works for me.

  6. #6
    Join Date
    May 2002
    Location
    Canada
    Posts
    3,339

    Default Re: Site search box

    Report back please.

  7. #7
    Join Date
    Aug 2000
    Location
    Placitas, New Mexico, USA
    Posts
    41,502

    Default Re: Site search box

    I use DuckDuckGo as my default search engine for the reasons Acorn mentioned. And it does not try to tailor search results to what it thinks are your preferences.

  8. #8

    Default Re: Site search box

    Quote Originally Posted by Acorn View Post
    I prefer DuckDuckGo as it does not track any search.

    Try this:

    Code:
    <iframe src="https://duckduckgo.com/search.html?width=650&kn=1&duck=yes&site=www.wonershhistory.co.uk&prefill=Search www.wonershhistory.co.uk&bgcolor=#003100&focus=yes&kn = 1 " style="overflow:hidden;margin:0;padding:0;width:783px;height:60px;" frameborder="0"></iframe>
    You can modify the search values from this page: https://duckduckgo.com/search_box. Original Post is here: https://www.talkgraphics.com/showthr...434#post570434.

    Acorn
    I have used the DuckDuckGo code and it works so thank you for that. Being really picky, is it possible to change the colour of the magnifying glass background (which is currently green)?

  9. #9
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,814

    Default Re: Site search box

    Quote Originally Posted by JFry View Post
    I have used the DuckDuckGo code and it works so thank you for that. Being really picky, is it possible to change the colour of the magnifying glass background (which is currently green)?
    I cannot think of any simple way as it is in a third-party IFRAME.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  10. #10

    Default Re: Site search box

    Quote Originally Posted by Acorn View Post
    I cannot think of any simple way as it is in a third-party IFRAME.

    Acorn
    Okay, thanks - it still looks good.

 

 

Bookmarks

Posting Permissions

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