|
javascript working fine in IE but cannot work in Firefox
Hi all,
I am new to javascript. I have this script working fine in IE but cannot work in firefox. Really appreciate on any guidance.
search0.js
- Code: Select all
function Search(str)
{
var textD=parent.textFrame.document;
var SearchRange = textD.body.createTextRange();
while(SearchRange.findText(str)){
SearchRange.select();
var sr = textD.selection.createRange();
try {sr.pasteHTML( "<font style='background:yellow' id='highlightedText'>"+ str + "</font>");}
catch (e) { alert(e.description); }
finally { SearchRange.collapse(false); }
}
SearchRange.collapse(true);
}
function makeArea(doc,map,cor,str)
{
var replicator = document.createElement("AREA");
replicator.shape = "rect";
replicator.coords = cor;
replicator.alt=str;
replicator.onclick=function (){Search(str)} ;
mapObj = doc.getElementById(map);
mapObj.appendChild(replicator);
}
function clearHighlite(){
parent.textFrame.location.reload(false);
} the HTML file that called the script
- Code: Select all
<html>
<title>Image</title>
<head>
<script language="JavaScript" src="Search0.js">
</script>
<script language="JavaScript" src="somedocument.txt"></script>
</head>
<body >
<button onclick="clearHighlite()">Clear Highlighting</button>
<img src="somedocument.bmp" usemap="#map" width=1000>
<map name="map" id="map">
<script language="JavaScript">
addAreas(document,"map")
</script>
</map>
</body>
</html>
Last edited by Lchad; May 21st, 2007 at 19:02.
Reason: added code tags
|