Skip to content Skip to sidebar Skip to footer

How To Make Popup Window In Javascript Only Show Once?

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 Javasc

Solution 1:

Just 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.

Solution 2:

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.com","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.

Solution 3:

<script>var popup;
</script><inputtype="button"onClick="if (!popup) popup = window.open('new.html');">

Post a Comment for "How To Make Popup Window In Javascript Only Show Once?"