Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple Pop Up Windows

    Hello!

    I'm trying to make a website that from one link, opens multiple windows. It is for a design project (I'm still at uni). So far I have mustered just the one window.

    Here is the website: http://popmeup.org/

    The idea is that you get bombarded with lots of nice quotes.

    I don't know my arse from my Javascript - but has anyone got any advice?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,147
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    Quote Originally Posted by tmyie View Post
    Hello!

    I'm trying to make a website that from one link, opens multiple windows. It is for a design project (I'm still at uni). So far I have mustered just the one window.

    Here is the website: http://popmeup.org/

    The idea is that you get bombarded with lots of nice quotes.

    I don't know my arse from my Javascript - but has anyone got any advice?
    Yes - forget it! To stop that sort of silly thing all modern browsers block unrequested popups.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, I know it's annoying. But the project is to play on the annoyance of pop up adverts, so I would like to be able to mimic it.

    So, it it not possible with modern browsers? I've managed to get the one popped.

    Thanks

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,147
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    Quote Originally Posted by tmyie View Post
    Yeah, I know it's annoying. But the project is to play on the annoyance of pop up adverts, so I would like to be able to mimic it.

    So, it it not possible with modern browsers? I've managed to get the one popped.

    Thanks
    If the user clicks on a link then the popup is not unrequested. But the user would have to request (invite) each popup separately. You cannot "bombard" people with unrequested windows.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Just as well this is for a uni project and not for the "real world"

    When the page finishes loading, it opens a new page for each quote in the quotesA array and writes a quote to its own page. The original window then closes leaving just the pages with quotes open.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
            <title></title>
            <style type="text/css"></style>
            <script type="text/javascript">
                var quotesA = ['quote 1','quote 2','quote 3'];
                window.onload=function(){
                    var newWins = [];
                    for(i=0; i<quotesA.length; i++){
                        newWins[i] = window.open();  //open a blank window
                        newWins[i].document.write('<h1>'+quotesA[i]+'</h1>');
                    }
                    self.close(); //close the original page
                }
            </script>
        </head>
        <body>
        </body>
    </html>
    But bear in mind that the user has the final say, with their browser settings, on whether newWins[i] opens a new window or a new tab in the one browser window. And in at least FF10, the user can block the above new windows in their browser settings. You cannot over-ride the user's preference.
    Last edited by webdev1958; 03-17-2012 at 02:55 AM.

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,147
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    self.close(); //close the original page

    Throws a warning message in IE.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #7
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Quote Originally Posted by Philip M View Post
    self.close(); //close the original page

    Throws a warning message in IE.
    And so it should Users should have the final say in whether they really want the window closed or not (like I posted earlier)


  •  

    Posting Permissions

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