JavaScript源文件未在IE8 Popup中加载 [英] JavaScript source file not loading in IE8 Popup

查看:115
本文介绍了JavaScript源文件未在IE8 Popup中加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个问题,即在IE6,Chrome,Firefox,Safari和Opera的弹出窗口中加载JavaScript源文件。但是在IE8中没有加载相同的源文件。

I have an issue where the JavaScript source file is loading in popup for IE6, Chrome, Firefox, Safari and Opera. But the same source file is not loading up in IE8.

因此 HTML没有在Popup中被替换我在IE8弹出窗口中收到错误,说 tinyMCE未定义

As a result of this the HTML is not being replaced in the Popup and I am getting an error in IE8 popup saying tinyMCE is not defined

我已提到格式化此JavaScript在IE8以外的所有浏览器上排除了并解决了问题。

I have referred to Formatting this JavaScript Line and solved issue on all browsers except IE8.

JavaScript函数如下:

The JavaScript function is as follows:

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');

    var winDoc = winId.document;
    var sEl = winDoc.createElement("script");
    sEl.src = "../js/tiny_mce/tiny_mce.js";/*TinyMCE source file*/
    sEl.type="text/javascript";
    winDoc.getElementsByTagName("head")[0].appendChild(sEl);

    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 () {/*using setTimeout to wait for the JS source file to load*/
        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();
    }, 300);
}




其他信息

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

请帮我这个。

推荐答案


  1. 为什么你使用实际的DOM函数来添加包含tinymce.js的< script> 标签,但其他一切都是使用document.write?

  1. Why are you using actual DOM functions to add the <script> tag that includes tinymce.js but everything else is using document.write?

我认为这也是你的问题所在,因为< head> < html> 之内,尚未在您要附加所述< script> 标记的位置关闭。

I think that's also where your problem lies, as <head> is within <html>, which is not yet closed where you want to append said <script> tag.

否则,您可以使用弹出窗口中的现有< script> 标记添加代码包括所需的外部JavaScript文件。如果这是有道理的。

Otherwise, you could use the existing <script> tag in the popup to add the code that includes the required external javascript file. If that makes any sense.

所以,基本上我说的是,尝试它的方式和其他一切一样在你的脚本中,使用 document.write

So, basically I'm saying, try it the same way as everything else is in your script, using document.write.

(快速添加)我不是说这是'最好的方法,我建议创建一个实际的页面,而不是在弹出窗口中动态创建一个。但在这种情况下,我认为我之前写的内容可能会解决您遇到的问题。

(quick addition) I'm not saying this is the 'best' way to do this, I would recommend creating an actual page instead of dynamically creating one in the popup. But in this scenario, I think what I wrote earlier might solve the problem you are having.

这篇关于JavaScript源文件未在IE8 Popup中加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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