我想在另一个窗口打开弹出窗口打开弹出窗口。
请检查代码 -
myjavascript.js
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}
的index.html
<script src="myjavascript.js"></script>
<a href="#" onclick="NewWindow('popup1.html','name','500','500','yes');return false" class="link-2">My Account</a>
popup1.html
<script src="myjavascript.js"></script>
<a href="#" onclick="NewWindow('popup2.html','name','500','500','yes');return false" class="link-2">Click to open popup2</a>
popup2.html
<h1>You are now popup2.html page</h1>
上面的代码对我有用,但第二个弹出窗口没有打开。请检查并告诉我。
由于 @chatfun
答案 0 :(得分:1)
问题是您为window.open(mypage,myname,settings)
使用了相同的标识符。
更改第二次调用中的name
:
<强>的index.html 强>
<a href="#" onclick="NewWindow('popup1.html','name','500','500','yes');return false" class="link-2">My Account</a>
<强> popup1.html 强>
<a href="#" onclick="NewWindow('popup2.html','NEWNAME','500','500','yes');return false" class="link-2">Click to open popup2</a>
希望这有帮助,