child.onload 在 IE8 中没有被调用,但在 Firefox 和 Chrome 中可以工作

发布于 2024-10-07 16:02:50 字数 1168 浏览 0 评论 0原文

当我单击超链接时,IE8 中不会调用 child.onload 函数。我不知道为什么,但在其他浏览器中可以工作。 也没有语法错误。这个片段是我从 html 文件中粘贴的。

另外,如果我使用 setTimeout 5 秒等分配子表单字段,那么它可以在 IE8 中工作。

JavaScript:

<script type="text/javascript">
function openWindow(){
    var child=window.open("index.php?option=com_aicontactsafe&pf=4&tmpl=component",'win2','width=400,height=350,menubar=yes,resizable=yes');

    if(child!==null) {
        child.onload=function() { 
            alert("In onload");
            child.document.getElementById("aics_ForDocument_Title").value=window.document.getElementById("documentname").innerHTML; 
            child.document.getElementById("aics_FormURL").value="$referer"; 
            child.document.getElementById("aics_FormURL").readOnly=true;
            };
        }
    return false;
}
</script>

HTML:

<div id="reportthis">
    <a href="#"  onclick=" openWindow();">
        <img src="images/instruments/reportthis.jpg" width="110" height="31" alt="Report This" title="Report this document for any issues" />
    </a>
</div>

When I click the hyperlink the child.onload function does not get called in IE8. I don't know why but works in other browsers.
Also there are no syntax errors. This snippet I've pasted from the html file.

Also if I assign the child form fields using setTimeout 5 sec etc then it's working in IE8.

JavaScript:

<script type="text/javascript">
function openWindow(){
    var child=window.open("index.php?option=com_aicontactsafe&pf=4&tmpl=component",'win2','width=400,height=350,menubar=yes,resizable=yes');

    if(child!==null) {
        child.onload=function() { 
            alert("In onload");
            child.document.getElementById("aics_ForDocument_Title").value=window.document.getElementById("documentname").innerHTML; 
            child.document.getElementById("aics_FormURL").value="$referer"; 
            child.document.getElementById("aics_FormURL").readOnly=true;
            };
        }
    return false;
}
</script>

HTML:

<div id="reportthis">
    <a href="#"  onclick=" openWindow();">
        <img src="images/instruments/reportthis.jpg" width="110" height="31" alt="Report This" title="Report this document for any issues" />
    </a>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文