IE8在JavaScript Popup上奇怪崩溃 [英] IE8 Crashes Strangely on JavaScript Popup

查看:153
本文介绍了IE8在JavaScript Popup上奇怪崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.


我正在使用 ** https ** 而不是 ** http ** 我觉得popup不是因为 SSL 而能够加载JS文件。

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

以下是如何我正在生成 onclick 事件:

Here is the how i am generating the onclick event:

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

onclick 函数以这种方式定义:

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(/&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();
    }

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

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


我已经提到这些帖子
已经:

I have referred to these posts already:

  • Importing js file in https page using http URL in IE8
  • Force Browser Mode=IE8 and document mode=IE8 Standards

其他信息

  • Screen shot of the page
  • Rendered HTML
  • Original JSPF


推荐答案

以下是解决我的问题的最终工作函数,适用于IE6,IE7,IE8,Chrome,Firefox,Safari和Opera。

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(/&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, ">");
        //hiddenFrameHTML2 = hiddenFrameHTML2.replace(/&amp;/gi, "&").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">");
        winId.document.write(hiddenFrameHTML2); 
        winId.document.write('</body></html>\n');
        winId.document.close();
    }, 300);
}

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

I got a lot of help from these questions:

  • Formatting this JavaScript Line
  • JavaScript source file not loading in IE8 Popup

谢谢大家。

这篇关于IE8在JavaScript Popup上奇怪崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆