hi
i have a textbox in the first page of the site and there is a submit button next to that for search about favorite product that is put there for inform customers that such a product there is or not and actually these items are inside of the form tag
i have another page and inside this page name of the products are written as a text , this page is specially for search in for example suppose products.html .
i have a javascript code that is called after that user typed name of favorite product inside of textbox and click submit button.
after click search button if there is such user's favorite product
user transform to products.html and matching names are highlighted and show to user.
but my problem is that my javascript code works in IE browser properly but unfortunately not in firefox
would you please help me.
my javascript code is as follow
in advance, i appreciate you
i have a textbox in the first page of the site and there is a submit button next to that for search about favorite product that is put there for inform customers that such a product there is or not and actually these items are inside of the form tag
i have another page and inside this page name of the products are written as a text , this page is specially for search in for example suppose products.html .
i have a javascript code that is called after that user typed name of favorite product inside of textbox and click submit button.
after click search button if there is such user's favorite product
user transform to products.html and matching names are highlighted and show to user.
but my problem is that my javascript code works in IE browser properly but unfortunately not in firefox
would you please help me.
my javascript code is as follow
Code:
<script language="javascript" type="text/javascript" >
var NS4 = (document.layers);
var IE4 = (document.all);
var win = window;
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("Not found.");
}
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("((unfortunately, there is'nt any product matching with yours)) ");
}
}
return false;
}
</script>
Comment