3

I need to open multiple urls on click of a button. Am testing on Chrome PS: I am doing this for myself. I am just trying to open all urls which i want to read daily in the morning. I don't want to waste time clicking on each url for example. Not sure if javascript is the right tool to build such functionality or not Wrote the following code and it's not opening, just opening the first and the last url

<html>
    <head>
        <title>Shopping</title>
        <script>               

            function Software()
            {
                window.open("http://forums.asp.net/", "status=1,toolbar=1,menubar=1");
                window.open("http://www.joelonsoftware.com/", "status=1,toolbar=1,menubar=1");
                window.open("http://blog.cwa.me.uk/", "status=1,toolbar=1,menubar=1");
                window.open("http://www.lifehacker.com/", "status=1,toolbar=1,menubar=1");
                window.open("http://www.Theverge.com", "status=1,toolbar=1,menubar=1");
                window.open("http://www.hanselman.com/", "status=1,toolbar=1,menubar=1");
                window.open("http://www.goodreads.com", "status=1,toolbar=1,menubar=1");
                window.open("http://www.stackoverflow.com", "status=1,toolbar=1,menubar=1");
            }

        </script>
    </head>
    <body>            
        <a href="http://www.channel9.msdn.com/" onclick="Software()">
            Software / Programming 
        </a>
    </body>
</html>
8
  • 2
    What browser do you use? Some browser may block pop-ups. Commented Feb 6, 2014 at 16:07
  • @Kiril Testing on Chrome. Commented Feb 6, 2014 at 16:08
  • 1
    I would say 90% of modern browsers will block this. Opening so many windows to different URLs is only going to look suspicious (and to be honest it is suspicious). You also have no control over when the browser will prevent this. Put simply, don't do this. No body ever likes this functionality Commented Feb 6, 2014 at 16:11
  • 1
    Most browsers are trying to prevent this sort of behavior because of misuse. Commented Feb 6, 2014 at 16:11
  • possible duplicate of Allow window.open to open new window and not popup Commented Feb 6, 2014 at 16:11

3 Answers 3

4

Give your windows unique names:

function Software() {
  window.open("http://forums.asp.net/", "w1", "status=1,toolbar=1,menubar=1");
  window.open("http://www.joelonsoftware.com/", "w2", "status=1,toolbar=1,menubar=1");
  window.open("http://blog.cwa.me.uk/", "w3", "status=1,toolbar=1,menubar=1");
  window.open("http://www.lifehacker.com/", "w4", "status=1,toolbar=1,menubar=1");
  window.open("http://www.Theverge.com", "w5", "status=1,toolbar=1,menubar=1");
  window.open("http://www.hanselman.com/", "w6", "status=1,toolbar=1,menubar=1");
  window.open("http://www.goodreads.com", "w7", "status=1,toolbar=1,menubar=1");
  window.open("http://www.stackoverflow.com", "w8", "status=1,toolbar=1,menubar=1");
}

Note that these links will open as actual windows, not tabs.

Demo: http://jsfiddle.net/9xBv7/

Sign up to request clarification or add additional context in comments.

3 Comments

I can see only the first url being opened in the demo
Multiple windows are open on top of each other - move the top window, you will see the rest
This triggers the default popup blocker in chrome so that only the first URL opens in a new window. All other URLs are not opened and are listed as being blocked from opening the popup blocker's UI.
2

If you're doing this for yourself, Chrome has a feature when you right click on a folder of bookmarks that offers you the choice to "Open All Bookmarks In a New Window".

The other options that might avoid the popup blocker logic are to write a small browser plugin or to use the command line to start an instance of the browser with a bunch of URLs.

Comments

0

You might want to try just setting your home page to open all those when your browser opens instead.

Link

Or you could embed them in IFrames in a page as well. That way you don't have to open a bunch of different windows.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.