XghostriderX
10-05-2003, 12:56 PM
This for all you script-guru's:
Yesterday I was trying to make a simple Jscript for my brother's homepage that allows to use different searchengines to search the web, but I was surprise when the script didn't work with Explorer, while it did with Opera 7.2.
Now here is what I wrote:
<HEAD>
<script type="text/javascript" >
function goToSearch()
{
if (window.event.keyCode == 13)
{
Search()
}
}
function Search()
{
term = window.document.searchform.querry.value ;
location.href ="http://www.google.nl/search?q=" + term
}
</script >
</head>
<body>
<FORM name="searchform">
<input type='text' size='20' name='querry' onKeyPress="goToSearch()">
<input type='button' size='10' value='Go' onclick="Search()">
</FORM>
bla blas
bla bla
.
.
.
.
</body>
did I do somthing wrong? Oh yeah I forgot the script works fine in Explorer & Opera in case I use the button instead of the Enter-key, but that just annoying. I mean everyone is use the type somethng in the the textfield and than hit the enter-key .
So the real problem is how to get this script to work with a the Enter-key?.
I tried onSumbit="", but that didn't work(It was a dumb move I know <_< ). I also tried to copy the body of the second function to the first one, but that also didn't help.
One thing that did work for all browers was the open commad, if I use window.open() instead of loction.href="", I get no problems at all except that my brother doesn't want that.
So any help would be aprceiated guys.
PS: I apologize if this the wrong place to post such a problem.
Yesterday I was trying to make a simple Jscript for my brother's homepage that allows to use different searchengines to search the web, but I was surprise when the script didn't work with Explorer, while it did with Opera 7.2.
Now here is what I wrote:
<HEAD>
<script type="text/javascript" >
function goToSearch()
{
if (window.event.keyCode == 13)
{
Search()
}
}
function Search()
{
term = window.document.searchform.querry.value ;
location.href ="http://www.google.nl/search?q=" + term
}
</script >
</head>
<body>
<FORM name="searchform">
<input type='text' size='20' name='querry' onKeyPress="goToSearch()">
<input type='button' size='10' value='Go' onclick="Search()">
</FORM>
bla blas
bla bla
.
.
.
.
</body>
did I do somthing wrong? Oh yeah I forgot the script works fine in Explorer & Opera in case I use the button instead of the Enter-key, but that just annoying. I mean everyone is use the type somethng in the the textfield and than hit the enter-key .
So the real problem is how to get this script to work with a the Enter-key?.
I tried onSumbit="", but that didn't work(It was a dumb move I know <_< ). I also tried to copy the body of the second function to the first one, but that also didn't help.
One thing that did work for all browers was the open commad, if I use window.open() instead of loction.href="", I get no problems at all except that my brother doesn't want that.
So any help would be aprceiated guys.
PS: I apologize if this the wrong place to post such a problem.