By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,962 Members | 1,889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,962 IT Pros & Developers. It's quick & easy.

Code works in IE but not in FF

P: n/a
Hi,

I have this piece of code which works in IE but not in FF. The code find all
words in actual page who correspond to str and highlight them.

Thanx for your help
<script language="JavaScript">

var win = window; // window to search.
var n = 0;

function findInPage(str) {
var txt, i, found;
var listEls = document.getElementsByTagName("span");

for (i = listEls.length - 1 ; i >= 0 ; i--) {
if (listEls[i].name == '__surligne__') {
var innerHTML = listEls[i].innerHTML;
listEls[i].outerHTML = innerHTML;
}
}

if (str == "")
return false;

txt = win.document.body.createTextRange();

while ( txt.findText(str) != false) {
txt.moveStart("character", -1);
txt.moveEnd("textedit");
txt.findText(str);
txt.pasteHTML('<span name="__surligne__" style="color:black;
background-color:yellow">' +str + '</span>');
}

return false;
}

</script>
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
lolo wrote:
[...]
var innerHTML = listEls[i].innerHTML;
Assigning innerHTML to a variable name may make innerHTML unavailable.
listEls[i].outerHTML = innerHTML;


Firefox does not support outerHTML, it is an IE thing (and maybe Opera,
but don't quote me).

--
Rob
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.