Forum Moderators: mack
I have noticed that several of our competitor sites are somehow able to "capture" a user's keyword phrase used to generate the SERPs and populate the exact phrase into a textbox on a form.
I would like to do the same thing as it would greatly improve the usability of our site. I am fairly proficient in ASP and HTML, but not much else. I am very willing to learn something new if it would result in the best solution. I am working in a windows environment.
Any help on getting started would be appreciated.
Thank you,
-cdogz
[pre]<html><head>
<script type="text/javascript">
function showTheQuery() {
$query = document.referrer.substring(document.referrer.indexOf('?')+1);
document.form.field.value = $query;
}
</script>
</head><body onload="showTheQuery()">
<FORM name=form>
<INPUT name=field type=text>
</FORM>
</body></html>[/pre] For example, if someone searches Google for "blue widgets", lands on the Google page with the url <http://www.google.com/search?q=blue+widgets&ie=UTF-8&oe=UTF-8>, then clicks over to your page, what will show up in your INPUT box is:
q=blue+widgets&ie=UTF-8&oe=UTF-8
Of course it's up to you to parse that data and make use of it.
You can also use Perl instead of Javascript to grab the referring query string and do useful things with it. Either way, you're gonna be getting into some programming.