[英]open a new window from another pop up javascript window
I'm trying to open a new window from another pop up java script window via writing html code in this pop up window, but it doesn't work, please help me as soon as possible. 我正在尝试通过在该弹出窗口中编写html代码从另一个弹出的Java脚本窗口中打开一个新窗口,但是它不起作用,请尽快帮助我。
<html>
<head>
<style>
.larger{ width:750px;}
.standard{ width:600px;}
.orginal{ width:10px;}
</style>
<script type="text/javascript">
function larger()
{
OpenWindow=window.open("", "larger","width=1000,scrollbars=yes");
OpenWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'+
'http://www.w3.org/TR/html4/strict.dtd">'+
'<html><head><title>Test page</title>'+
'<style type="text/css">'+
'.larger{ width:750px;}'+
'</style></head><body>');
OpenWindow.document.write('<a href="#" onclick="standard()">high</a>');
OpenWindow.document.write("<img id='img1' src='webfonts.jpg'>");
OpenWindow.document.write('</body></html>');
OpenWindow.document.close();
OpenWindow.document.getElementById("img1").className = "larger";
}
function standard()
{
OpenWindow=window.open("", "newwin",'width=600,scrollbars=yes');
OpenWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'+
'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'+
'<html><head><title>Test page</title>'+
'<style type="text/css">'+
'.standard{ width:600px;}'+
'</style></head><body>');
OpenWindow.document.write("<img id='img1' src='webfonts.jpg'>");
OpenWindow.document.write('</body></html>');
OpenWindow.document.close();
OpenWindow.document.getElementById("img1").className = "standard";
}
</script>
</head>
<body>
<img class="orginal"id="img1" src="webfonts.jpg" border="0" />
<span onclick="larger()"><a href="#">fig1</a></span>
</body>
</html>
您已经在第一个父脚本中创建了标准函数,并尝试从子弹出窗口中调用它,这当然不会在其中定义此函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.