admin管理员组文章数量:1332107
I want to make single pop up window in javascript. No matter how many times the button is pressed from parent page, only the single pop up is activated.
How can I do that in Javascript?
I want to make single pop up window in javascript. No matter how many times the button is pressed from parent page, only the single pop up is activated.
How can I do that in Javascript?
Share Improve this question edited Oct 5, 2011 at 1:54 Jared Farrish 49.2k17 gold badges99 silver badges107 bronze badges asked Oct 5, 2011 at 1:52 kitokidkitokid 3,11718 gold badges66 silver badges104 bronze badges 2- What is the purpose of the JSP tag? – Jared Farrish Commented Oct 5, 2011 at 1:53
- I was going to suggest using a cookie, but I like the other solutions here instead because they don't require Cookies to be enabled which you can't always assume. – Yzmir Ramirez Commented Oct 5, 2011 at 2:02
3 Answers
Reset to default 4Just give the window a fixed name. So, don't do
window.open('popup.jsp');
but do
window.open('popup.jsp', 'chooseHereYourFixedName');
It will then be reused.
The window.open
method takes 3 parameters.
- a URL
- a Name
- a list of arguments
As long as the Name portion is the same when you open the popup, the same window will be reused.
window.open ("http://www.google.","mywindow","status=1");
Here's another idea.
Why not create an inline page popup (div) with an iFrame inside? Fancybox does this pretty easily along with a number of other frameworks. Pretty easy to write with custom Javascript as well.
This way your users will never navigate from your window and only that popup will ever live from clicking the button.
<script>
var popup;
</script>
<input type="button" onClick="if (!popup) popup = window.open('new.html');">
本文标签: How to make popup window in javascript only show onceStack Overflow
版权声明:本文标题:How to make popup window in javascript only show once? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742273899a2444827.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论