Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open multiple pop-up windows?

I have five links and each links to a page.

function TohokuImgPopup(url) { 
popupWindow = window.open(
                    url, 'popUpWindow'+randomno, 'height=246,width=228,left=0,top=0,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no')
            }

This is the function I am using. I have different function for the 5 links, each opens a new window. But I am only able to open one popup at a time. How can I open multiple popups?

like image 787
Gravity M Avatar asked Sep 15 '13 19:09

Gravity M


People also ask

How do I open multiple popup windows in asp net?

You can have multiple popups by changing the popup window name (pass the ID string as a second parameter, and make the ID the popup name, for example). They'll stay open, but they will not all stay on top of the main page.


2 Answers

I found the answer.

<script type="text/javascript">

$(document).ready(


function a1(url) { 
popupWindow1 = window.open(
                    url, 'popUpWindow1', 'height=250,width=234,left=0,top=0,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no')
            }

            function a2(url) { 
popupWindow2 = window.open(
                    url, 'popUpWindow2', 'height=250,width=234,left=0,top=0,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no')
            }

            function a3(url) { 
popupWindow3 = window.open(
                    url, 'popUpWindow3', 'height=308,width=299,left=0,top=0,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no')
            }
            }
</script>

<a href="JavaScript:a1('images/focus_img1.html');">focus 1</a>
<a href="JavaScript:a2('images/focus_img2.html');">focus 2</a>
<a href="JavaScript:a3('images/focus_img3.html');">focus 3</a>

These links will be opened in separate windows

like image 143
Gravity M Avatar answered Sep 27 '22 22:09

Gravity M


I know it's been a long time since the question was asked, but i'll answer because I found nothing on the web that clearly answer the question. An easy way is to use a link with an click() event.

$('body').on('click', 'a[data-popup]', function(e) {
  var date = new Date();
  var mSec = date.getTime();
  my_window = window.open($(this).attr('href'), "Popup"+mSec, "top=0,left=0,menubar=no,toolbar=no,location=no, height=600, width=800");
  e.preventDefault();
  my_window.focus();
});

using the date.getTime() (It is impossible to have any return value repeated since it's the amount of seconds since 1970 january 1st...) makes each new popup window with a new name :)

like image 44
Olivier Bérubé Avatar answered Sep 27 '22 20:09

Olivier Bérubé