Google search on my site?

  • Tone2k11
  • Proficient
  • Proficient
  • Tone2k11
  • Posts: 493
  • Loc: Southampton - UK

Post 3+ Months Ago

Hi all,

Im new to webbuilding and am trying to get a google search on my site? is this possible? if so as anyone got the code for it?

I appriciate you takin the time to read this.

Thanks in advance

Tony :D
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Is this what your looking for ?
http://www.google.com/apis/


Or, this will popup a new window with google results.
Code: [ Select ]
<html>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function askGoogle(query){
    googleAdr = "http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=";
    queryFull = googleAdr + query;
    window.open(queryFull,"_BLANK");
}
// -->
</SCRIPT>
</HEAD>

<body>
<input type="text" id="terms">
<input type="button" value="Ask Google" onclick="askGoogle(terms.value);">


</body>
</html>
  1. <html>
  2. <HEAD>
  3. <SCRIPT LANGUAGE="JavaScript">
  4. <!--
  5. function askGoogle(query){
  6.     googleAdr = "http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=";
  7.     queryFull = googleAdr + query;
  8.     window.open(queryFull,"_BLANK");
  9. }
  10. // -->
  11. </SCRIPT>
  12. </HEAD>
  13. <body>
  14. <input type="text" id="terms">
  15. <input type="button" value="Ask Google" onclick="askGoogle(terms.value);">
  16. </body>
  17. </html>
  • Smilingwolf
  • Novice
  • Novice
  • User avatar
  • Posts: 31

Post 3+ Months Ago

I added a google search to a my site and it required a key that is provided from google. It allows you to make 1000 searches per day. I used a module made for Xoops to do this.
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Well, since you asked I took a little time and made this...
Just put this part in your header of your search page:
Code: [ Select ]
<script type="text/javascript">
function googleload()
{
document.f.submit()
}
</script>
  1. <script type="text/javascript">
  2. function googleload()
  3. {
  4. document.f.submit()
  5. }
  6. </script>

Then you will need a if statement to tell if the form has yet been submitted so, put something like this:
Code: [ Select ]
<? if(isset($_GET[q])) {
$url = "yoursite.com";?>
<body bgcolor=white onload="load()">
yea this is sc0rp.ath.cx
<form action="http://www.google.com/search" name=f>
<table cellspacing=0 cellpadding=0>
 <tr>
  <td width=75>&nbsp;</td>
  <td align=center>
    <input type=hidden name=hl value=en>
    <span id=hf></span>
    <input type=hidden name=ie value="UTF-8">
    <input type=hidden name=oe value="UTF-8">
    <input maxLength=256 size=55 name=q value="<? echo "site:$url $_GET[q]"; ?>">
    <br><input type=submit value="Google Search" name=btnG>
    </td></tr></table></form>
  1. <? if(isset($_GET[q])) {
  2. $url = "yoursite.com";?>
  3. <body bgcolor=white onload="load()">
  4. yea this is sc0rp.ath.cx
  5. <form action="http://www.google.com/search" name=f>
  6. <table cellspacing=0 cellpadding=0>
  7.  <tr>
  8.   <td width=75>&nbsp;</td>
  9.   <td align=center>
  10.     <input type=hidden name=hl value=en>
  11.     <span id=hf></span>
  12.     <input type=hidden name=ie value="UTF-8">
  13.     <input type=hidden name=oe value="UTF-8">
  14.     <input maxLength=256 size=55 name=q value="<? echo "site:$url $_GET[q]"; ?>">
  15.     <br><input type=submit value="Google Search" name=btnG>
  16.     </td></tr></table></form>

Then you will need the form that would regularly show up, this could be on another also, and then you would really need the if statement above but you would need all other code.
Code: [ Select ]
<? } else { ?>
<body bgcolor="white">
<form action="<?=$PHP_SELF?>" name=f>
<table cellspacing=0 cellpadding=0>
 <tr>
  <td width=75>&nbsp;</td>
  <td align=center>
    <input type=hidden name=hl value=en>
    <span id=hf></span>
    <input type=hidden name=ie value="UTF-8">
    <input type=hidden name=oe value="UTF-8">
    <input maxLength=256 size=55 name=q value="">
    <br><input type=submit value="Google Search" name=btnG>
    </td></tr></table></form>
<? } ?>
  1. <? } else { ?>
  2. <body bgcolor="white">
  3. <form action="<?=$PHP_SELF?>" name=f>
  4. <table cellspacing=0 cellpadding=0>
  5.  <tr>
  6.   <td width=75>&nbsp;</td>
  7.   <td align=center>
  8.     <input type=hidden name=hl value=en>
  9.     <span id=hf></span>
  10.     <input type=hidden name=ie value="UTF-8">
  11.     <input type=hidden name=oe value="UTF-8">
  12.     <input maxLength=256 size=55 name=q value="">
  13.     <br><input type=submit value="Google Search" name=btnG>
  14.     </td></tr></table></form>
  15. <? } ?>

I tested this on my server first and it seemed to work just fine, just change the $url variable to your site. If you have any problems, you can IM me on just about any messanger, or PM me.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 55 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.