我有一个用ASP.NET生成的HTML页面,parent.aspx,我想单击超链接打开一个弹出窗口,其中包含一个已经存在的html页面,article.html并将元素从parent.aspx附加到html页面。这两个文件,parent.aspx和article.html位于相同的文件夹中。用Javascript打开一个弹出窗口,并附上父窗口的元素
的article.html,除了含有标准元件,例如标题和正文,内部主体具有只是没有既不内容也不节点一个div,用作占位符的内容,以附加
parent.aspx
<a href="javascript:displayPopup('article.html');">Open Article</a>
<div id="articleContent">
<table>
<!--article content-->
</table>
</div>
article.html
<body>
<div id="article"></div>
</body>
的Javascript
function displayPopup(url) {
var popupWindow;
var width = 960;
var height = 700;
var left = parseInt((screen.availWidth/2) - (width/2));
var top = parseInt((screen.availHeight/2) - (height/2));
var articleContent = document.getElementById("articleContent").innerHTML;
var windowProperties = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top + ",scrollbars=yes";
popupWindow = window.open(url, 'article', windowProperties);
var articleDiv = popupWindow.document.getElementById("article");
articleDiv.innerHTML += articleContent;
popupWindow.document.close();
if (window.focus)
{ popupWindow.focus() }
}
我把代码中jsFiddle,虽然我不能插入两个不同的HTML页面,有只为parent.aspx的标记。该代码在调试模式下工作,但由于某种原因,它不在正常执行过程中。我无法发现错误,请有人帮忙吗?谢谢!
更新:如果我检查身体内的弹出窗口的代码,我有
<body>
<div id="article" class="content"> </div>
<script type="text/javascript" src="https://www.pc-gizmos-ssl.com:9899/scripts/main.js?ver=1.0.0.6">
<form id="GM_form" target="_blank"></form>
</body>
我不知道在哪里的PC-小玩意脚本是从
谢谢,但问题依然存在。它只能在调试模式下工作 – CiccioMiami
感谢您的提示,请参阅我的更新代码 – CiccioMiami
而不是追加到文章div,请尝试替换div中的所有内容。换句话说,而不是使用'articleDiv.innerHTML + = articleContent;'尝试'articleDiv.innerHTML = articleContent;'脚本是否包含pc-gizmos现在? – j03z