IE8 在 JavaScript 弹出窗口上奇怪地崩溃

发布于 2024-09-04 00:22:59 字数 4270 浏览 2 评论 0原文

创建弹出窗口后,我遇到了一个奇怪的问题onclick。弹出窗口打开,但在 IE8 上立即挂起(在包括 IE6 在内的所有其他浏览器上工作正常)。但是,在添加 JavaScript 代码中所示的 alert 框后,弹出窗口工作正常。

我使用的是 **https** 而不是 **http** 并且我觉得弹出窗口无法加载 JS 文件,因为 SSL.

以下是我生成 onclick 事件的方式:

<a id="forgotPasswordLink" href="#" onclick="openSupportPage();"> Some Text </a>

onclick 函数是这样定义的:

        function openSupportPage() {
            var features = "width=700,height=400,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes";
            var winId = window.open('', '', features);
            winId.focus();
            winId.document.open();
            winId.document.write('<html><head><title>' + document.title + '</title><link rel="stylesheet" href="./css/default.css" type="text/css">\n');
            var is_ie6 = (
            window.external && typeof window.XMLHttpRequest == "undefined");
            alert(is_ie6);/*The JS include below*/
                          /*works in popup only with this alert box.*/
                          /*else IE8 Hangs*/
                winId.document.write('<script src="../js/tiny_mce/tiny_mce.js" type="text/javascript">Script_IE8</script>\n');


            winId.document.write('<script type="text/javascript">\n');
            winId.document.write('function inittextarea() {\n');
            winId.document.write('tinyMCE.init({  \n');
            winId.document.write('elements : "content",\n');
            winId.document.write('theme : "advanced",\n');
            winId.document.write('readonly : true,\n');
            winId.document.write('mode : "exact",\n');
            winId.document.write('theme : "advanced",\n');
            winId.document.write('readonly : true,\n');
            winId.document.write('setup : function(ed) {\n');
            winId.document.write('ed.onInit.add(function() {\n');
     winId.document.write('tinyMCE.activeEditor.execCommand("mceToggleVisualAid");\n');
            winId.document.write('});\n');
            winId.document.write('}\n');
            winId.document.write('});}</script>\n');
            winId.document.write('</head><body onload="inittextarea()">\n');
            winId.document.write('  \n');
            var hiddenFrameHTML = document.getElementById("HiddenFrame").innerHTML;
            hiddenFrameHTML = hiddenFrameHTML.replace(/&amp;/gi, "&");
            hiddenFrameHTML = hiddenFrameHTML.replace(/&lt;/gi, "<");
            hiddenFrameHTML = hiddenFrameHTML.replace(/&gt;/gi, ">");
            winId.document.write(hiddenFrameHTML);
            winId.document.write('<textarea id="content" rows="10" style="width:100%">\n');
            winId.document.write(document.getElementById(top.document.forms[0].id + ":supportStuff").innerHTML);
            winId.document.write('</textArea>\n');
            var hiddenFrameHTML2 = document.getElementById("HiddenFrame2").innerHTML;
            hiddenFrameHTML2 = hiddenFrameHTML2.replace(/&amp;/gi, "&");
            hiddenFrameHTML2 = hiddenFrameHTML2.replace(/&lt;/gi, "<");
            hiddenFrameHTML2 = hiddenFrameHTML2.replace(/&gt;/gi, ">");
            winId.document.write(hiddenFrameHTML2);
            winId.document.write('</body></html>\n');
            winId.document.close();
    }

请帮助我解决这个问题。如果需要,我可以提供更多相关信息。

我参考过这些帖子 已经:

其他信息

I am facing a strange issue after the popup is created onclick. The popup opens up but hangs immediately on IE8 (works fine on all the other browsers including IE6). But on adding the alertbox as show in the JavaScript code, the popup works fine.

I am using **https** and not **http** and i feel popup is not able to load the JS file because of SSL.

Here is the how i am generating the onclick event:

<a id="forgotPasswordLink" href="#" onclick="openSupportPage();"> Some Text </a>

The onclick function is defined this way:

        function openSupportPage() {
            var features = "width=700,height=400,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes";
            var winId = window.open('', '', features);
            winId.focus();
            winId.document.open();
            winId.document.write('<html><head><title>' + document.title + '</title><link rel="stylesheet" href="./css/default.css" type="text/css">\n');
            var is_ie6 = (
            window.external && typeof window.XMLHttpRequest == "undefined");
            alert(is_ie6);/*The JS include below*/
                          /*works in popup only with this alert box.*/
                          /*else IE8 Hangs*/
                winId.document.write('<script src="../js/tiny_mce/tiny_mce.js" type="text/javascript">Script_IE8</script>\n');


            winId.document.write('<script type="text/javascript">\n');
            winId.document.write('function inittextarea() {\n');
            winId.document.write('tinyMCE.init({  \n');
            winId.document.write('elements : "content",\n');
            winId.document.write('theme : "advanced",\n');
            winId.document.write('readonly : true,\n');
            winId.document.write('mode : "exact",\n');
            winId.document.write('theme : "advanced",\n');
            winId.document.write('readonly : true,\n');
            winId.document.write('setup : function(ed) {\n');
            winId.document.write('ed.onInit.add(function() {\n');
     winId.document.write('tinyMCE.activeEditor.execCommand("mceToggleVisualAid");\n');
            winId.document.write('});\n');
            winId.document.write('}\n');
            winId.document.write('});}</script>\n');
            winId.document.write('</head><body onload="inittextarea()">\n');
            winId.document.write('  \n');
            var hiddenFrameHTML = document.getElementById("HiddenFrame").innerHTML;
            hiddenFrameHTML = hiddenFrameHTML.replace(/&/gi, "&");
            hiddenFrameHTML = hiddenFrameHTML.replace(/</gi, "<");
            hiddenFrameHTML = hiddenFrameHTML.replace(/>/gi, ">");
            winId.document.write(hiddenFrameHTML);
            winId.document.write('<textarea id="content" rows="10" style="width:100%">\n');
            winId.document.write(document.getElementById(top.document.forms[0].id + ":supportStuff").innerHTML);
            winId.document.write('</textArea>\n');
            var hiddenFrameHTML2 = document.getElementById("HiddenFrame2").innerHTML;
            hiddenFrameHTML2 = hiddenFrameHTML2.replace(/&/gi, "&");
            hiddenFrameHTML2 = hiddenFrameHTML2.replace(/</gi, "<");
            hiddenFrameHTML2 = hiddenFrameHTML2.replace(/>/gi, ">");
            winId.document.write(hiddenFrameHTML2);
            winId.document.write('</body></html>\n');
            winId.document.close();
    }

Please help me on this one. I could provide more information on this if needed.

I have referred to these posts
already:

Additional Information:

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞笑我太脆弱 2024-09-11 00:22:59

这是最终的工作功能,它解决了我的问题,并适用于 IE6、IE7、IE8、Chrome、Firefox、Safari 和 Opera。

function openSupportPage() {
    var features="width=700,height=400,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes";            
    var winId=window.open('','',features);
    winId.document.open();
    winId.document.write('<html><head><title>' + document.title + '</title><link rel="stylesheet" href="../css/default.css" type="text/css">\n');

    window.setTimeout(function () {
        winId.document.write(
          '<script src="../js/tiny_mce/tiny_mce.js" type="text/javascript"></scr' + 'ipt>\n'
        );
    }, 10);

    winId.document.write('<script type="text/javascript">\n');
    winId.document.write('function inittextarea() {\n');
    winId.document.write('tinyMCE.init({  \n');  
    winId.document.write('elements : "content",\n');
    winId.document.write('theme : "advanced",\n');
    winId.document.write('readonly : true,\n');
    winId.document.write('mode : "exact",\n');
    winId.document.write('theme : "advanced",\n');
    winId.document.write('readonly : true,\n');
    winId.document.write('setup : function(ed) {\n');
    winId.document.write('ed.onInit.add(function() {\n');
    winId.document.write('tinyMCE.activeEditor.execCommand("mceToggleVisualAid");\n');
    winId.document.write('});\n');
    winId.document.write('}\n');
    winId.document.write('});}</script>\n');

    window.setTimeout(function () {
        winId.document.write('</head><body onload="inittextarea()">\n');
        winId.document.write('  \n');
        var hiddenFrameHTML = document.getElementById("HiddenFrame").innerHTML;
        hiddenFrameHTML = hiddenFrameHTML.replace(/&/gi, "&");
        hiddenFrameHTML = hiddenFrameHTML.replace(/</gi, "<");
        hiddenFrameHTML = hiddenFrameHTML.replace(/>/gi, ">");
        winId.document.write(hiddenFrameHTML); 
        winId.document.write('<textarea id="content" rows="10" style="width:100%">\n');
        winId.document.write(document.getElementById(top.document.forms[0].id + ":supportStuff").innerHTML);
        winId.document.write('</textArea>\n');
        var hiddenFrameHTML2 = document.getElementById("HiddenFrame2").innerHTML;
        hiddenFrameHTML2 = hiddenFrameHTML2.replace(/&/gi, "&");
        hiddenFrameHTML2 = hiddenFrameHTML2.replace(/</gi, "<");
        hiddenFrameHTML2 = hiddenFrameHTML2.replace(/>/gi, ">");
        //hiddenFrameHTML2 = hiddenFrameHTML2.replace(/&/gi, "&").replace(/</gi, "<").replace(/>/gi, ">");
        winId.document.write(hiddenFrameHTML2); 
        winId.document.write('</body></html>\n');
        winId.document.close();
    }, 300);
}

我从这些问题中得到了很多帮助:

谢谢大家。

Here is the final working function which solved my issue and works in IE6, IE7, IE8, Chrome, Firefox, Safari and Opera.

function openSupportPage() {
    var features="width=700,height=400,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes";            
    var winId=window.open('','',features);
    winId.document.open();
    winId.document.write('<html><head><title>' + document.title + '</title><link rel="stylesheet" href="../css/default.css" type="text/css">\n');

    window.setTimeout(function () {
        winId.document.write(
          '<script src="../js/tiny_mce/tiny_mce.js" type="text/javascript"></scr' + 'ipt>\n'
        );
    }, 10);

    winId.document.write('<script type="text/javascript">\n');
    winId.document.write('function inittextarea() {\n');
    winId.document.write('tinyMCE.init({  \n');  
    winId.document.write('elements : "content",\n');
    winId.document.write('theme : "advanced",\n');
    winId.document.write('readonly : true,\n');
    winId.document.write('mode : "exact",\n');
    winId.document.write('theme : "advanced",\n');
    winId.document.write('readonly : true,\n');
    winId.document.write('setup : function(ed) {\n');
    winId.document.write('ed.onInit.add(function() {\n');
    winId.document.write('tinyMCE.activeEditor.execCommand("mceToggleVisualAid");\n');
    winId.document.write('});\n');
    winId.document.write('}\n');
    winId.document.write('});}</script>\n');

    window.setTimeout(function () {
        winId.document.write('</head><body onload="inittextarea()">\n');
        winId.document.write('  \n');
        var hiddenFrameHTML = document.getElementById("HiddenFrame").innerHTML;
        hiddenFrameHTML = hiddenFrameHTML.replace(/&/gi, "&");
        hiddenFrameHTML = hiddenFrameHTML.replace(/</gi, "<");
        hiddenFrameHTML = hiddenFrameHTML.replace(/>/gi, ">");
        winId.document.write(hiddenFrameHTML); 
        winId.document.write('<textarea id="content" rows="10" style="width:100%">\n');
        winId.document.write(document.getElementById(top.document.forms[0].id + ":supportStuff").innerHTML);
        winId.document.write('</textArea>\n');
        var hiddenFrameHTML2 = document.getElementById("HiddenFrame2").innerHTML;
        hiddenFrameHTML2 = hiddenFrameHTML2.replace(/&/gi, "&");
        hiddenFrameHTML2 = hiddenFrameHTML2.replace(/</gi, "<");
        hiddenFrameHTML2 = hiddenFrameHTML2.replace(/>/gi, ">");
        //hiddenFrameHTML2 = hiddenFrameHTML2.replace(/&/gi, "&").replace(/</gi, "<").replace(/>/gi, ">");
        winId.document.write(hiddenFrameHTML2); 
        winId.document.write('</body></html>\n');
        winId.document.close();
    }, 300);
}

I got a lot of help from these questions:

Thank you all.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文