Hi i have this script that i want to use as php or html but i cant find the problem, could anyone solve the problem, i dont know why i cannot use it in php or html file
// OBS! Några saker måste justeras för att skriptet skall fungera
// 1) Du måste ange antal webbsidor som skall genomsökas
// 2) Du måste lista dessa webbsidor
// 3) Du måste justera variabeln mode (1= visa title, 2=visa länkar,
// 3 = visa båda)
//
// Antal webbsidor som skall genomsökas. Ändra nedan i
// variabeln nrOfPages
//
var nrOfPages=12;
var mode=1
var page=new Array(nrOfPages);
//
//
// Lista webbsidorna här nedan som skall genomsökas.
// Ange fullständig sökväg inkl. http://
//
page[0]='http://www.htmlsidan.se';
page[1]='http://www.htmlsidan.se/?visa=artiklar';
page[2]='http://www.htmlsidan.se/?visa=skriptarkiv';
page[3]='http://www.htmlsidan.se/?visa=designer';
page[4]='http://www.htmlsidan.se/?visa=webb';
page[5]='http://www.htmlsidan.se/?visa=service';
page[6]='http://www.htmlsidan.se/demo/ajax_sok_05.html';
page[7]='http://www.htmlsidan.se/?visa=tipsotrix';
page[8]='http://www.htmlsidan.se/?visa=links';
page[9]='http://www.htmlsidan.se/?visa=topp_def';
page[10]='http://www.htmlsidan.se/?visa=fm_rules';
page[11]='http://www.htmlsidan.se/?visa=other_stuff';
//
// Här nedan behöver du inte ändra någonting.
//
//
var pageNr=0;
var searchWord="";
var result="";
var ingetHittat=0;
var nav=navigator.userAgent.toLowerCase();
var title="";
function search(word)
{
result="";
pageNr=0;
ingetHittat=0;
result=result+"<b>Söker efter ""+word+"" ...</b><br/>";
setText("search_result",result);
searchPages(word);
}
function searchPages(word)
{
searchWord=word;
var httpRequest = getHttpRequest();
httpRequest.onreadystatechange = function()
{
handleRequest(httpRequest);
};
httpRequest.open('GET', page[pageNr], true);
httpRequest.send(null);
}
function handleRequest(handle)
{
var text="";
if (handle.readyState != 4)
{
return;
}
if (handle.status && (handle.status == 404) || (handle.status == 2))
{
alert('Webbsida eller fil saknas '+page[pageNr]);
return;
}
if (handle.status && handle.status != 200)
{
alert('Felkod ' + handle.status );
return;
}
text= handle.responseText;
text=text.replace(/(\n)/g,"***");
text=text.replace(/(\n)/g,"");
matches=text.match(/(<title.*?</title>)/gi);
title=matches[0];
title=title.replace(/(<.*?>)/gi,"");
text=text.replace(/(<style*?</style)/gi,"");
text=text.replace(/(<script.*?</script>)/gi,"");
text=text.replace(/(<title.*?</title>)/gi,"");
text=text.replace(/(<noframes.*?</noframes>)/gi,"");
text=text.replace(/(&.*?;)/gi,"");
text=text.replace(/(<.*?>)/gi,"");
text=text.replace(/(***)/g,"\n");
text=text.toLowerCase();
if (text.match(searchWord.toLowerCase())!=null)
{
if (mode==3)
{
title=title+" "+page[pageNr];
}
if (mode==2)
{
title=page[pageNr];
}
result=result+"» <a href=""+page[pageNr]+"">"+title+"</a><br/>";
setText("search_result",result);
ingetHittat=1;
}
if (++pageNr<nrOfPages)
{
searchPages(searchWord);
}
else
{
if (ingetHittat==0)
{
result=result+"hittade ingenting";
setText("search_result",result);
}
}
}
function getHttpRequest()
{
var handle = false;
if (window.XMLHttpRequest)
{
handle = new XMLHttpRequest();
if(handle.overrideMimeType) // Mozilla/Safari/IE7+
{
handle.overrideMimeType('text/xml; charset=iso-8859-1');
}
}
else
if (window.ActiveXObject)
{
try
{
handle = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
handle = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
if (!handle)
{
return false;
}
return handle;
}
function setText(namn,txt)
{
if (document.all)
{
document.all[namn].innerHTML=txt;
}
else if (document.layers)
{
document[namn].document.open();
document[namn].document.write(txt);
document[namn].document.close();
}
else if (document.getElementById)
{
document.getElementById(namn).innerHTML=txt;
}
}
5 1851
That's javascript, mate.
I suggest you try reading the posting guidelines before you post another load of unstyled code.
Regards, markus.
That's javascript, mate.
I suggest you try reading the posting guidelines before you post another load of unstyled code.
Regards, markus.
i know its javascript but can i make it to php
i know its javascript but can i make it to php
I, aswell as everyone else, have no idea what the script does. Therefore, i cannot possibly attempt to convert it to php.
Maybe some explanation of what it does would help? Maybe.
Regards.
9 times out of 10 javascript cannot be converted TO php because javascript is NOTHING like php. They work under different environments.
I, aswell as everyone else, have no idea what the script does. Therefore, i cannot possibly attempt to convert it to php.
Maybe some explanation of what it does would help? Maybe.
Regards.
9 times out of 10 javascript cannot be converted TO php because javascript is NOTHING like php. They work under different environments.
hi again, this is a script for a search engine and the website that i took from said that i could make it to php by using this line or something header('text/html; charset=iso-8859-1'); could you check it out, mix little with the script and see if you could make it php?
Thanks
hi again, this is a script for a search engine and the website that i took from said that i could make it to php by using this line or something header('text/html; charset=iso-8859-1'); could you check it out, mix little with the script and see if you could make it php?
Thanks
It seems that you have to write backend for this AJAX-based tool.
Good luck :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Petre Huile |
last post by:
I have designed a site for a client, but they have hired an internet
marketing person to incrase their search engine ranking and traffic.
He wants to put extra-large fonts on every page which will...
|
by: vic |
last post by:
My manager wants me to develop a search program, that would work like they
have it at edorado.com.
She made up her requirements after having compared how search works at
different websites, like...
|
by: vichet |
last post by:
Hi All;
Please help me with some problem
i want VBSCRIPT to search something in only my own website
give me code
thank
vichet
|
by: Patrick |
last post by:
Are the differences between a search engine, a subject directory and a
meta search engine significant for an ebusiness web site owner?
A meta search engine merely uses ordinary existing search...
|
by: Dave |
last post by:
I have created a program that maintains our inventory in a
database and allows Web shoppers to browse the catalog
using ASP.Net. This is intended to replace our current
web site which was created...
|
by: hazly |
last post by:
I'm very new in the web technology and need advice on search engine. I
want to develop a portal using PHP and MySQL on Linux. Need to know on
the following features :
1. search engine that could...
|
by: MDW |
last post by:
Posted this on another board, but evidently it was off-topic there...hope you
folks will be able to provide some guidance.
I've been working on a Web site for a business (my first non-personal...
|
by: Sheau Wei |
last post by:
This is the search engine code that i create, but it was error and didnt come out the result. Cn u help me to check what wrong with my code?
Thanks
<Table cellspacing=1 cellPadding=1...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |