IE8 Crashes Strangely on JavaScript Popup(IE8 在 JavaScript 弹出窗口上奇怪地崩溃)
问题描述
创建弹出窗口后,我遇到了一个奇怪的问题onclick
.弹出窗口打开但在 IE8 上立即挂起(在包括 IE6 在内的所有其他浏览器上都可以正常工作).但是在添加 alert
框时,如 JavaScript 代码所示,弹出窗口工作正常.
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 alert
box as show in the JavaScript code, the popup works fine.
我使用的是 **https**
而不是 **http**
,我觉得弹出窗口无法加载 JS 文件,因为 SSL
.
I am using
**https**
and not**http**
and i feel popup is not able to load the JS file because ofSSL
.
这是我生成 onclick
事件的方式:
Here is the how i am generating the onclick
event:
<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">
');
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>
');
winId.document.write('<script type="text/javascript">
');
winId.document.write('function inittextarea() {
');
winId.document.write('tinyMCE.init({
');
winId.document.write('elements : "content",
');
winId.document.write('theme : "advanced",
');
winId.document.write('readonly : true,
');
winId.document.write('mode : "exact",
');
winId.document.write('theme : "advanced",
');
winId.document.write('readonly : true,
');
winId.document.write('setup : function(ed) {
');
winId.document.write('ed.onInit.add(function() {
');
winId.document.write('tinyMCE.activeEditor.execCommand("mceToggleVisualAid");
');
winId.document.write('});
');
winId.document.write('}
');
winId.document.write('});}</script>
');
winId.document.write('</head><body onload="inittextarea()">
');
winId.document.write('
');
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%">
');
winId.document.write(document.getElementById(top.document.forms[0].id + ":supportStuff").innerHTML);
winId.document.write('</textArea>
');
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>
');
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:
- 使用http URL在https页面中导入js文件在 IE8 中
- 强制浏览器模式=IE8和文档模式=IE8标准
其他信息:
- 页面截图
- 呈现的 HTML
- 原始 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">
');
window.setTimeout(function () {
winId.document.write(
'<script src="../js/tiny_mce/tiny_mce.js" type="text/javascript"></scr' + 'ipt>
'
);
}, 10);
winId.document.write('<script type="text/javascript">
');
winId.document.write('function inittextarea() {
');
winId.document.write('tinyMCE.init({
');
winId.document.write('elements : "content",
');
winId.document.write('theme : "advanced",
');
winId.document.write('readonly : true,
');
winId.document.write('mode : "exact",
');
winId.document.write('theme : "advanced",
');
winId.document.write('readonly : true,
');
winId.document.write('setup : function(ed) {
');
winId.document.write('ed.onInit.add(function() {
');
winId.document.write('tinyMCE.activeEditor.execCommand("mceToggleVisualAid");
');
winId.document.write('});
');
winId.document.write('}
');
winId.document.write('});}</script>
');
window.setTimeout(function () {
winId.document.write('</head><body onload="inittextarea()">
');
winId.document.write('
');
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%">
');
winId.document.write(document.getElementById(top.document.forms[0].id + ":supportStuff").innerHTML);
winId.document.write('</textArea>
');
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>
');
winId.document.close();
}, 300);
}
我从这些问题中得到了很多帮助:
I got a lot of help from these questions:
- 格式化此 JavaScript 行
- JavaScript 源文件未在 IE8 弹出窗口中加载
谢谢大家.
这篇关于IE8 在 JavaScript 弹出窗口上奇怪地崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:IE8 在 JavaScript 弹出窗口上奇怪地崩溃
基础教程推荐
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01