我正试图通过下面的href链接实现2件事情。首先,我想启动一个弹出式窗口。完成。接下来,我想弹出窗口来显示一个iframe。这很容易完成,以及,直到我意识到我需要通过href链接文本作为我的iframe src中的参数。弹出窗口中的动态iframe
所以举例来说,在我的弹出窗口的iframe不会加载,除非其src="http://localhost:8080/test/document.html?OnSale"
我想不通,为什么在我的HTML网页正文中的document.write
不会打印出动态的iframe我试着去创造我FOO()在href链接功能...
<div id="blanket" style="display:none;"></div>
<div id="popUpDiv" style="display:none;">
<a href="#" onclick="popup('popUpDiv')">
<img align="right" src="http://localhost:8080/test/img/close_img.png">
</a>
<script type="text/javascript">
function foo(obj)
{
test1 = "http://localhost:8080/test/document.html?"+obj.text;
document.write('<iframe height="450" allowTransparency="true" frameborder="0" scrolling="yes" style="width:100%;" src="'+test1+'" type= "text/javascript"></iframe>');
}
</div>
<a href="#" onclick="popup('popUpDiv');foo(this);">OnSale</a>
编辑: 这里是我的全部HTML页面。所有东西都在tomcat7 w/win7和firefox上本地运行。
<html>
<head>
<script type="text/javascript" src="http://localhost:8080/test/css-popup/css-pop.js"></script>
<link href="http://localhost:8080/test/css-popup/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="blanket" style="display:none;"></div>
<div id="popUpDiv" style="display:none;">
<a href="#" onclick="popup('popUpDiv')">
<img align="right" src="http://localhost:8080/test/css-popup/x.png">
</a>
<script type="text/javascript">
function foo(obj){
test1 = "http://localhost:8080/test/document.html?"+obj.innerHTML;
document.write('<iframe height="450" allowTransparency="true" frameborder="0" scrolling="yes" style="width:100%;" src="'+test1+'" type= "text/javascript"></iframe>');
}
</script>
</div>
<a href="#" onclick="popup('popUpDiv');foo(this);">OnSale</a>
</body>
</html>
我感谢帮助ocanal。 innerHTML也没有做到这一点,但这很好的了解文字不是标准的 – Chris
@Chris,再看看我更新的答案。 – ocanal
ocanal,谢谢!这完全打开了iframe,但它在Firefox中打开为新选项卡,而不是弹出窗口。有没有什么办法可以弹出window.open(n)而不是新标签? – Chris