jQuery打开窗口,但仅当尚未打开窗口时;然后在其他窗口前显示它? [英] jquery open window but only when window is not opened already; then show it in front of other windows?
问题描述
是否可以在click div上打开一个窗口,但前提是该窗口以前没有打开过?不是模态,而是一个具有一定大小(例如300x300)的常规窗口.
Would it be possible to have on click div open a window but only if that window hasn't opened before? Not modal but just a regular window with a certain size say 300x300.
我有这个Jsfiddle,但还没有完全正常工作.想法是有一个弹出窗口,如果已经打开,则将其推到前面.
I have this Jsfiddle but not fully working yet. The idea is to have 1 popup window and just push it in the front if its already opened.
推荐答案
您可以使用以下内容:
$("#element_id").click(function(){
window.open ("http://your-domain.com/your-url.html","my_window","menubar=1,resizable=1,width=350,height=250");
});
基本上,每次执行此window.open命令时,由于使用相同的窗口名称(在本例中为"my_window"),将使用同一窗口...
Basically every time you execute this window.open command, the same window will be utilized because of the same window name ("my_window" in this case)...
我希望这会有所帮助:)
I hope this helps :)
这篇关于jQuery打开窗口,但仅当尚未打开窗口时;然后在其他窗口前显示它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!