Hello everyone!
First sorry for my English.
Can someone help me to change
the search method in my page with another
better search method.
This is the perfect search-method
I need to work only with IE.
I want to search with this method in my
<HTML><HEAD><TITLE>perfect seaching</TITLE>
<META content=”text/html; charset=windows-1251″ http-equiv=Content-Type>
<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
var NS4 = (document.layers);
var IE4 = (document.all);
var win = this;
var n = 0;
function findInPage(str) {
var txt, i, found;
if (str == “”)
return false;
if (NS4) {
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if (n == 0) alert(str + ” was not found on this page.”);
}
if (IE4) {
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart(“character”, 1);
txt.moveEnd(“textedit”);
}
if (found) {
txt.moveStart(“character”, -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
else {
if (n > 0) {
n = 0;
findInPage(str);
}
else
alert(str + ” was not found on this page.”);
}
}
return false;
}
// End –>
</script>
</HEAD>
<BODY>
<form name=search onSubmit=”return findInPage(this.string.value);”>
<b>Search here:</b> <input name=string type=text size=15 onChange=”n = 0;”>
<INPUT type=submit value=start>
</form>
</body></html>
This is my page with not perfect search-method.
The search results are not correct.
Example – try to find info about
<html>
<head>
<title>Basic Data Binding</title>
<META HTTP-EQUIV=”Content-Type” CONTENT=”text/html; charset=windows-1251″>
</head>
<body bgcolor=082984>
<!– Data source object: file parameters –>
<object id=”selectlist” width=”0″ height=”0″ classid=”clsid:333C7BC4-460F-11D0-BC04-0080C7055A83″>
<param name=”DataURL” value=”MyDatabase.txt”>
<param name=”FieldDelim” value=”;”>
<param name=”UseHeader” value=”true”>
</object>
<h2>Simple search</h2>
<form name=”SearchResults”>
Query First name: <input id=”query” value=”” /><button onclick=”SearchAble();”>search</button><br />
<button onclick=”Clear();”>Clear</button>
</form>
<script type=”text/javascript”>
<!–
page=”<html><head><title>Search Results</title><style>.avn {color:red;}</style></head><body bgcolor=’f0f0f0′ leftmargin=3 topmargin=3 text=’blue’><center><table border=0 cellspacing=0 cellpadding=2 width=100%><font face=Arial size=3>”;
function SearchAble() {
if (document.SearchResults.query.value == “”){
win = parent.middle(“”,”secId5874″,”scrollbars=1″);
win.document.write(“write something”);
win.document.close();
}
else{
SearchTable()
}
}
function SearchTable() {
win = parent.middle(“”,”secId5874″,”scrollbars=1″);
//win.document.write(page);
var list=””;
var result=0;
var objRegexEx=null;
var objRegex=new RegExp(document.SearchResults.query.value, “i”)
selectlist.recordset.MoveFirst();
for (var i = 1; i <= selectlist.recordset.AbsolutePosition; i++) {
objRegexEx=new RegExp(selectlist.recordset(“first”), “i”)
if( objRegex.test(selectlist.recordset(“first”)) || objRegexEx.test(document.SearchResults.query.value)) {
list=”+selectlist.recordset(“last”)+”;
}
selectlist.recordset.MoveNext();
}
//Display list
win.document.write(page+FormatResults(list)+'</font></table></body></html>’);
win.document.close();
}
function FormatResults(result) {
var listing=””;
var last=””;
result=result.split(” “);
last='<div style=”color:black;white-space:nowrap; font-size:9pt;”>’;
for(var i=2; i<result.length; i++) {
last+=result[i]+” “;
}
last+='</div>’;
listing+='<div style=”font-size:larger;”>’+result[0]+'</div><div style=”font-family?honeticTM;”>’+result[1]+'</div>’+last;
return listing;
}
function Clear() {
win = parent.middle(“”,”secId5874″,”scrollbars=1″);
win.document.write(page);
win.document.close();
document.SearchResults.query.value = “”;
}
//–>
</script>
<IFRAME name=”middle” width=”223″ scrolling=”auto” height=”267″ src=”nach.html” frameborder=0 style=”border-style: inset; border-width: 2px”></IFRAME>
</body>
</html>
[COLOR=blue]
P.S. Contents of the data file “MyDatabase.txt” – example:
First;Last
a;a word1 word2 word3 word4 word5 word6
able;able word1 word2 word3 word4 word5 word6
absolutely;absolutely word1 word2 word3 word4 word5 word6
accept;accept word1 word2 word3 word4 word5 word6
I;I word1 word2 word3 word4 word5 word6
ice;ice word1 word2 word3 word4 word5 word6
idea;idea word1 word2 word3 word4 word5 word6
if;if word1 word2 word3 word4 word5 word6
ill;ill word1 word2 word3 word4 word5 word6
important;important word1 word2 word3 word4 word5 word6
impossible;impossible word1 word2 word3 word4 word5 word6
impulse;impulse word1 word2 word3 word4 word5 word6
in;in word1 word2 word3 word4 word5 word6
speak;speak word1 word2 word3 word4 word5 word6