I was working on coding my second PHProxy theme a few days ago and wanted to add Google Search functionality to it. I had that planned since I started the
design. I'm not great at Javascript, so I had no clue how to do it. A
friend helped me do it, and I'd like to share.
What it Does
It adds Google Search functionality to a proxy site. You don't need to enter
www.google.com in the textbox to go to Google, and then search. Instead, you can enter a search query in the same textbox and click on Google search. This is something I've never seen before on proxies.
Preview
Go
here and click on test.
How to do it
Add this between your head tags:
Code:
<script language="JavaScript" type="text/javascript">
function submitForm()
{
document.FORM_NAME.submit();
}
</script>
<script language="JavaScript" type="text/javascript">
function google(){
text = document.FORM_NAME.TEXT_FIELD_NAME.value;
document.a.q.value = "http://google.com/search?q=" + text;
}
</script>
I know the coding isn't great, but what it does it when someone clicks on the Google Search button on your page, the second script will write the search url, and the first script will submit it.
On the Google Search button, you need this:
Code:
onclick="google(),submitForm()"
That's it
I'd appreciate it if you link to my
site,
share it, or just subscribe to my
RSS feed for other free designs.