PDA

View Full Version : Search From Google



DannyBoy
01-26-2008, 08:26 AM
I was wondering how I would create a little search engine using javascript. What it will do is it will allow you to type a word in a box and press search and then when you click the button a new window will open and load the search in google.

jscheuer1
01-26-2008, 04:56 PM
No javascript required:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>
<form action="http://www.google.com/search" method="get" target="_blank">
Search: <input type="text" name="q"> <input type="submit" value="Go!">
</form>
</body>
</html>

However, javascript can be used to enhance control over the window:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function ogoo(e){
if (e&&(e.type=='click'||window.event&&e.keyCode&&e.keyCode==13)){
ogoo.win=window.open('','goowin','height=400, width=550');
ogoo.win.focus();
}
}
</script>
</head>
<body>
<form action="http://www.google.com/search" method="get" target="goowin">
Search: <input type="text" name="q" onkeydown="ogoo(event);return true;">
<input onclick="ogoo(event);return true;" type="submit" value="Go!">
</form>
</body>
</html>