高手请进,iframe搜索问题,困扰好久了
-------请高人指点!!!谢谢-------
在iframe内包含一个mht文件,要对mht文件里面的内容进行搜索,我写了下面的代码,但是点页内查找报错:错误:拒绝访问 错误指向的代码是“txt = win.document.frames("body1").document.body.createTextRange();” 然后网页上的菜单就点不动了,也做不了其他操作,
-------请高人指点!!!谢谢---------
jsp代码:
<input type="text" id="searchstr" name="searchstr" class="textbox" size="10">
<input type="button" value="页内查找" onclick="javascript:findIt();" class="sbttn">
------iframe--------
<iframe name="body1" id="body1" marginWidth="0" marginHeight="0" height="1000" src=mhtml:http://localhost:7001/internet/wiki/3333.mht frameBorder="0" width="100%" scrolling="no"></iframe>
<!--对iframe内的mht文件进行页内搜索,搜索代码如下:
<script language="JavaScript">
<!--
function findIt() {
if (document.getElementById("searchstr").value != "")
findInPage(document.getElementById("searchstr").value);
}
function findInPage(str) {
var txt, i, found;
if (str == "")
return false;
if (IE4) {
txt = win.document.frames("body1").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("未找到指定内容.");
}
}
return false;
}
------------>
</SCRIPT>
-->