Skip to content
WJunction - Webmaster Forum

How to enable google search function in static website ?

Status
Not open for further replies.

Ar!yaN

Distinguished Member
3,446
2009
504
Can anyone help with code of google search thing in normal static html website ?with help of javascript ?like in my site search bar what ever i type i just got a result from google search.
 

3 comments

Code:
<script type="text/javascript">


var domain="www.yourdomain_name"


function cgsearch(sterm){
sterm.s.value="site:"+domain+" "+sterm.sf.value
}


</script>




<form action="http://www.google.com/search" method="get" onSubmit="cgsearch(this)">


<p>Search:<br />
<input name="s" type="hidden" />
<input name="sf" type="text" style="width: 180px" /> <input type="submit" value="Search" /></p>


</form>
 
there is no site domain , as it is only static site, i tried to do with this code , but what i write in search inbox google only show the main page not resultmine code of form is
code - Pastebin.com
 
Last edited by a moderator:
its the same procedure when we looked on google for site indexing
by adding prefix site:
so if u dnt have even site,so how could google index them?


thats only reason of using custom google search on board

when people searching on custom google search bar of a web site, it shows the result respect to that website
And it gets work only when your site already indexed on google.com
Other wise it would not
 
Status
Not open for further replies.

About the author

Ar!yaN
Distinguished Member · Joined
3,446
Messages
504
Reactions
113
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom