Forum Moderators: open
Here's the original JavaScript from Google to add a standard web search box to a website:
<!-- Search Google -->
<center>
<FORM method=GET action="http://www.google.com/search">
<input type=hidden name=ie value=UTF-8>
<input type=hidden name=oe value=UTF-8>
<TABLE bgcolor="#FFFFFF"><tr><td>
<A HREF="http://www.google.com/">
<IMG SRC="http://www.google.com/logos/Logo_40wht.gif"
border="0" ALT="Google" align="absmiddle"></A>
<INPUT TYPE=text name=q size=25 maxlength=255 value="">
<INPUT type=submit name=btnG VALUE="Google Search">
</td></tr></TABLE>
</FORM>
</center>
<!-- Search Google -->
Here's the JavaScript you need to find only mp4 files.
<!-- Search Script -->
function submitform() {
var new_query="intitle:index.of \"mp4\" \"" +document.gs.query.value +"\"-htm -html -php -asp \"Last Modified\"";
document.gs.query.value=new_query;
}
<!-- End Search Script -->
How can I put these 2 things together to create a revised Google search code that implements the above JavaScript to make a specialty Google search happen for .mp4 files?
Thank you very much!
<script>
function submitform() {
var new_query="intitle:index.of \"mp4\" \"" +document.gs.query.value +"\"-htm -html -php -asp \"Last Modified\"";
document.getElementById('google_query').value=new_query;
document.google_search_form.submit();
}
</script>
<center>
<FORM name="google_search_form" method=GET action="http://www.google.com/search">
<input type=hidden name=ie value=UTF-8>
<input type=hidden name=oe value=UTF-8>
<TABLE bgcolor="#FFFFFF"><tr><td>
<A HREF="http://www.google.com/">
<IMG SRC="http://www.google.com/logos/Logo_40wht.gif"
border="0" ALT="Google" align="absmiddle"></A>
<INPUT TYPE=text name=q size=25 maxlength=255 value="">
<INPUT type=button onclick="submitform()" id="google_query" name=btnG VALUE="Google Search">
</td></tr></TABLE>
</FORM>
</center>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-GB">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
body {
background-color:#FFFFFF;
color:#000066;
margin-left: 100px;
margin-top: 10px;
margin-right: 100px;
margin-bottom: 10px;
height:100%;
overflow:auto;
font-family: Arial,Verdana,Helvetica,sans-serif;
font-size:12px;
}
.myGoogle {
text-align: center! important;
margin-left:auto;
margin-right:auto;
margin-top:auto;
margin-bottom:auto;
}
.gImage{
vertical-align: middle;
}
img{
border: none;
}
</style>
<script type="text/javascript">
function myOnloadEvent()
{
document.myGoogleForm.t.value = '';
document.myGoogleForm.q.value = '';
}
function appendGoogleQueryString()
{
var myQueryString = ' mp4 -htm -html -php -asp "Last Modified"';
// ENSURE THERE IS A SPACE BETWEEN THE ' AND THE mp4
myQueryString = document.myGoogleForm.t.value + myQueryString;
document.myGoogleForm.q.value = myQueryString;
document.myGoogleForm.submit();
}
</script>
<title>Check_Uncheck
</title>
</head>
<body onLoad="myOnloadEvent();">
<h1>
Header
</h1>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam semper nonummy tortor. Donec lobortis, vitae interdum.Suspendisse
</p>
<!-- Search Google -->
<form name="myGoogleForm" method="get" action="http://www.google.com/search">
<p class="myGoogle">
<input type="hidden" name="ie" value="utf-8"/>
<input type="hidden" name="oe" value="utf-8"/>
<a href="http://www.google.com/"/>
<img src="http://www.google.com/logos/Logo_40wht.gif"
alt="google"
class="gImage"></a>
<input type="text" name="t" size="25" maxlength="255" value=""/>
<input type="hidden" name="q"/>
<input type="button" name="btnGS" value="Google Search" onclick="appendGoogleQueryString();"/>
</p>
</form>
<!-- /Search Google -->
<p>
Aliquam vel mauris. Fusce ultrices, mi et pellentesque tincidunt, nisi risus dignissim libero, ac vulputate orci sem ut nibh. Etiam lacus dolor
</p>
<p>
Nam commodo libero nec justo. Sed diam risus, suscipit eu, feugiat eget, varius vel, dui. Pellentesque scelerisque ligula volutpat nunc. Praesent neque.
</p>
</body>
</html>
In the meantime, I've made a new search engine to search for multiple different things. Here is the full HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">
<title>Use the form below to search for</title>
<meta name="Microsoft Theme" content="water 1011, default">
</head>
<script>
url="";
function searchIt(){
var src = document.getElementById('search').value;
if(document.getElementById('type').value=="1")url="http://www.google.com/search?hl=en&lr=&safe=off&q=intitle%3Aindex.of+%2B%E2%80%9Dlast+modified%E2%80%9D+%2B%E2%80%9Dparent+directory%E2%80%9D+%2B%28mp3%7Cwma%7Cogg%29+%2B%22"+src+"%22+-htm+-html+-php+-asp&btnG=Search";
if(document.getElementById('type').value=="2")url="http://www.google.com/search?hl=en&lr=&safe=off&q=site%3Amegaupload.com+%2B%22"+src+"%22+%2B%28rar%7Czip%29&btnG=Search";
if(document.getElementById('type').value=="3")url="http://search.yahoo.com/search?p=%22"+src+"%22&mobid=U0Rgc6gM6%40OUcAAJgIKTw&mobvs=1&ei=UTF-8&xargs=12KPjg1CZSgoS8jfanBceVBLH4mglp49%5F2jLp7DOVsHKFk5jIvBKZyCvyB55wmFvll6wzVzoPFr7IUKfCPmLK7FBLXdRGBQtOhgc5t%2D4qVAJXiDIAF1OtOk6mswsINa00DYR9QTtMoqqydk%2Dj6S3YCzYkBPS1r3Plz3e%2DELdUOGPfq2%2DJa7BHmIAs55BIbgMzTVy87T6%5FgTds1oiwiQq9C3Zosxaq9rhe6JIuu%5Fdc7Fl6ARAAnqpzOCI4cu6pVrH%2DuW%2DL6idtY21Ki94Bi7B06%2DUrMmp9gQnuGqINp&pstart=9&fr=ystg-c&b=1";
if(document.getElementById('type').value=="4")url="http://www.google.com/search?hl=en&lr=&q=-inurl%3Ahtm+-inurl%3Ahtml+intitle%3A%22index+of%22+%2B%28%22%2Febooks%22%7C%22%2Fbook%22%29+%2B%28chm%7Cpdf%7Czip%29+%2B%22"+src+"%22%20%22Last%20Modified%22&btnG=Search";
if(document.getElementById('type').value=="5")url="http://www.google.com/search?hl=en&lr=&safe=off&q=intitle%3Aindex.of+%2B%E2%80%9Dlast+modified%E2%80%9D+%2B%E2%80%9Dparent+directory%E2%80%9D+%2B%28qcp%7Cmid%7Cm4a%7Cmp4%29+%2B%22"+src+"%22+-htm+-html+-php+-asp&btnG=Search";
if(document.getElementById('type').value=="6")url="http://www.google.com/translate?langpair=en¦en&u="+src;
parent.gog.location.href=url;
}
onload = checkCookie;
function checkCookie(){
var tsrc = document.cookie;
var src="";
for (var i=0; i<=tsrc.length;i++)
{
if(tsrc.charAt(i)!="+"){
src+=tsrc.charAt(i);
}else{
break;
}
}
var type = tsrc.charAt(i+1);
document.getElementById('type').value = type;
document.getElementById('search').value = src;
document.cookie = "";
searchIt();
}
function getIt(key){
if (key==13) searchIt();
}
</script>
<style>
body{
font:12px Verdana;
color:#B4C835;
font-weight: bold;
}
#support{
position: absolute;
top: 64px;
width: 468px;
left: 305px;
}
#adSpace{
position: absolute;
top: 4px;
left: 300px;
height: 60px;
width: 468px;
background: gray;
color: white;
text-align: center;
}
#didNot{
position: absolute;
top: 3px;
left: 800px;
height: 70px;
width: 230px;
}
#sub{
position: absolute;
top: 41px;
left: 150px;
}
.style1 {color: #FFFFFF}
</style>
</head>
<body onkeypress="getIt(event.keyCode)">
<p><label for="search">You Searched : </label><input type="text" id="search" /></p>
Type :
<select id="type">
<option value="1">Songs</option>
<option value="2">Album</option>
<option value="3">Software</option>
<option value="4">eBooks</option>
<option value="5">Ringtones</option>
<option value="6">prox-ify</option>
</select>
<div id="sub">
<input type="button" value="Search" onClick="searchIt()"/>
</div>
</body>
</html>
The problem is that when I click "Search" nothing happens! Where did I go wrong? Thank you!