Hello,
j'ai un petit probleme. Je connait pas du tout le javascript, et j'ai donc charché un script (SNARK :http://www.cs.cmu.edu/~jab/snark/) pour une search-machine pour placer sur mon site. Mon site est fait avec des frames et le probleme est que, quand je fait un submit il me ouvre la page dans mon frame de mon site, mais j'aimerais qu'il ce ouvre dans une nouvelle page d'explorer. Comment Faire????? HELP!!!!
Ici le script:
<SCRIPT>
<!-- hide this script from non-JavaScript browsers
// Distribution Rights Granted to: http://www.web-search.com/
// All code in this script is Copyright(C) 1996, Justin Boyan
// For documentation and more info, see: http://www.cs.cmu.edu/~jab/snark/
// This is SNARK Version 1.0, 18 May 1996
var MAX_ENGINES = 75;
var SNARK_STRING = "hunting+the+snark";
function MakeArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 0;
}
this.maxlen = n;
this.len = 0;
return this;
}
var engs = new MakeArray(MAX_ENGINES);
function find_substring(needle, haystack) {
var i, needlen = needle.length, haylen = haystack.length;
for (i=0; i<=haylen-needlen; i++) {
if (needle == haystack.substring(i,i+needlen))
return i;
}
return false;
}
function Engine(name, opts, home, search) {
var snark = find_substring(SNARK_STRING, search);
this.name = name;
this.opts = opts;
this.home = home;
this.pre_snark = search.substring(0,snark);
this.post_snark= search.substring(snark+SNARK_STRING.length, search.length);
}
function Add(name, opts, home, search) {
engs.len++;
if (engs.len <= engs.maxlen) {
engs[engs.len] = new Engine(name, opts, home, search)
}
else {
alert("Better increase MAX_ENGINES: " + engs.len + ">" + engs.maxlen)
}
}
// ADD YOUR OWN SEARCH ENGINES BELOW. (See http://www.cs.cmu.edu/~jab/snark/ )
Add("Web-Search.Com", "SELECTED",
"http://www.web-search.com",
"http://www.web-search.com/cgi-bin/person2.cgi?comp1col3col5=any&col1col3col5=hunting+the+snark&link1=2&wrapoff1=%3CBR%3E&wrapoff3=%3Cp%3E&snap=ul&sort=col4rev");
Add("Google", "",
"http://www.Google.com",
"http://www.google.ch/search?q=hunting+the+snark");
Add("NorthernLight", "",
"http://www.northernlight.com",
"http://www.northernlight.com/nlquery.fcg?cb=0&qr=hunting+the+snark");
Add("AllTheWeb", "",
"http://www.alltheweb.com",
"http://www.alltheweb.com/search?cat=web&lang=any&query=hunting+the+snark");
Add("About.Com", "",
"http://www.about.com/",
"http://searchpartners.about.com/texis/metaresults?site=websrch&terms=hunting+the+snark" );
Add("Lycos", "",
"http://www.lycos.com/",
"http://search.lycos.com/main/default.asp?lpv=1&loc=searchhp&query=hunting+the+snark" );
Add("GoTo", "",
"http://www.goto.com/",
"http://www.goto.com/d/search/?type=home&tm=1&Keywords=hunting+the+snark" );
Add("Altavista", "",
"http://www.altavista.com/",
"http://www.altavista.com/sites/search/web?q=hunting+the+snark" );
Add("Yahoo", "",
"http://www.yahoo.com",
"http://search.yahoo.com/search?o=1&p=hunting+the+snark&d=y&za=default&h=s&g=0&n=10");
// ADD YOUR OWN SEARCH ENGINES ABOVE. (See http://www.cs.cmu.edu/~jab/snark/ )
function HandleForm(form) {
form.submit(); // This fixes a mysterious Netscape bug. Without this line,
// you can't use <enter> to start the search the first time.
var i, oldq=form.query.value, newq="";
for (i=0; i<oldq.length; i++) { // compress [ ]+ into \+
var thischar = oldq.charAt(i);
if (thischar != ' ')
newq += thischar;
else if (lastchar != ' ')
newq += '+';
lastchar = thischar;
}
var eng = engs[1+form.service.selectedIndex];
location.href = newq ? eng.pre_snark + newq + eng.post_snark : eng.home;
}
function DisplayForm() {
document.writeln('<CENTER><FORM OnSubmit="HandleForm(this); return false">');
document.writeln('<SELECT name="service">');
for (i=1; i <= engs.len; i++) {
document.writeln("<OPTION " + engs[i].opts + "> " + engs[i].name);
}
document.writeln('</SELECT> <INPUT size=18 name="query">');
document.writeln('<input type=submit value=" Submit">');
document.writeln('<input type=reset value=" Reset">');
document.writeln('</FORM> </CENTER>');
}
DisplayForm();
// done hiding from old browsers -->
</SCRIPT>