如何更改弹出窗口的位置 [英] How To Change a Popup Window's Location

查看:74
本文介绍了如何更改弹出窗口的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 函数newPopup(url,windowName){
window.open(url,windowName,'height = 768,width = 1366,left = 10,top = 10,titlebar = no,toolbar = no,menubar = no,location = no,directories = no,status = no );
}
< a href =JavaScript:newPopup('lobby.do','lobby');> Enter Lobby< / a>

在该弹出窗口中,我希望用户能够通过单击来移动该弹出窗口的位置一个链接:

 < a href =game.do>新游戏< / a> 

但是,当在弹出窗口中点击此链接时,弹出窗口会自动关闭,重定向不会发生。我试着添加一个onClick并使用javaScript:window.location,但得到相同的结果。任何想法可能会造成这种情况?我已经在Chrome和Firefox中进行了测试。

解决方案

只需将链接的目标设置为弹出窗口的名称即可。

 < a href =game.dotarget =lobby>新游戏< / a> 

或者保存从 window.open 并设置其 .location

 函数newPopup(url,windowName ){
return window.open(url,windowName,'height = 768,width = 1366,left = 10,top = 10,titlebar = no,toolbar = no,menubar = no,location = no,directories =没有,状态=无');
}

< a onclick =window.lobby = newPopup('lobby.do','lobby'); return false; href =#>输入大厅< / a>
< a href =window.lobby.location ='game.do'; return false; href =#>新游戏< / a>


I have a popup window being opened by my application as follows:

function newPopup(url, windowName) {
    window.open(url,windowName,'height=768,width=1366,left=10,top=10,titlebar=no,toolbar=no,menubar=no,location=no,directories=no,status=no');
}
<a href="JavaScript:newPopup('lobby.do', 'lobby');">Enter Lobby</a>

Inside that popup window, I want the user to have the ability to move that popup's window location by clicking a link:

<a href="game.do">New Game</a>

However, when click this link in the popup window, the popup is automatically closed and the redirect does not happen. I've tried adding an onClick and using javaScript:window.location, but get the same results. Any idea what could be causing this? I've tested in both Chrome and Firefox.

解决方案

Just set the target of the link to the popup's name.

<a href="game.do" target="lobby">New Game</a>

Or save the value returned from window.open and set its .location.

function newPopup(url, windowName) {
    return window.open(url,windowName,'height=768,width=1366,left=10,top=10,titlebar=no,toolbar=no,menubar=no,location=no,directories=no,status=no');
}

<a onclick="window.lobby=newPopup('lobby.do', 'lobby'); return false;" href="#">Enter Lobby</a>
<a href="window.lobby.location='game.do'; return false;" href="#">New Game</a>

这篇关于如何更改弹出窗口的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆