SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Creating more than 1 popup window and avoid the popup blocker warning

    This is interesting, I have a code that creates some popup windows using window.open, if I create only 1, the popup blocker doesn't say a thing, but if I try to create 2 at once, the first one is displayed and the second one triggers the popup blocker.

    In the example, GetLinks() is the function that will open the 2 windows, and the individual windows are DisplayOne() and DisplayTwo() functions.

    Any ideas about how to open both without a problem?

    Code:
    <BUTTON type="button" onClick="GetLinks()" name="MyButton">Open Them</BUTTON>
    
    .
    .
    .
    .
    
    <script language="JavaScript">
    
    function GetLinks() {
    
    DisplayOne();
    DisplayTwo();
    
    }
    
    </script>
    
    .
    .
    .
    <script language="JavaScript">
    
    function DisplayOne() {
             window.open("http://www.google.com","","width=500,height=500");
    }
    
    function DisplayTwo() {
             window.open("http://www.Yahoo.com","","width=500,height=500,left=100,top=100");
    }
    
    </script>

  2. #2
    SitePoint Addict NikoB's Avatar
    Join Date
    Nov 2005
    Location
    Austria
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you cant open both. afaik current popup blockers allow one new window per click. So if you click the browser is allowed to open one window as a result. everything else is considered an unwanted popup. You can only avoid this if you whitelist the site...
    Corinis OpenSource Community & Content Management
    http://www.corinis.org

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mmmmmmm...That's what I thought but I wasn't sure.

    Any tricks to avoid this?

  4. #4
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jack_In_The_Box
    Mmmmmmm...That's what I thought but I wasn't sure.

    Any tricks to avoid this?
    Honestly, if there were I sure hope nobody tells you. Nothing personal but wouldnt you thinkt that work-around would be exploited by the very same people popup-blockers were designed to block?

  5. #5
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know, I was just being a "wise-***".

    But, I have a workaround, instead of opening 2 popups, I open just 1 with 2 frames, that gives me the desired effect.

    Thanks.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,799
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    One popup can be annoying (particularly if you didn't ask for it). More than one popup is deinitely annoying and should never be allowed. On the other hand having a popup blocker block a single popup window that you asked for from appearing is also annoying.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  7. #7
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree on the popups, however, due the nature of this app, this was needed.

    For example, say that you want to do a search and you have 3 options to select a search engine, Google, Yahoo or Both, and the user selected Both, 2 windows should open one querying Google and the other Yahoo.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •