Solved

I have to be able to open several new tabs by the click of a button

Posted on 2012-12-27
11
286 Views
Last Modified: 2012-12-27
Hi. I have an internal Content Management System program that I am working on.
I need to be able to open multiple tabs by a click of a button.

Right now i have this:
function editAll() {
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=608', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=607', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=612', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=606', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=605', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=604', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=603', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=602', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=601', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=600', '_blank', 'toolbar=0,location=0,menubar=0');
window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=599', '_blank', 'toolbar=0,location=0,menubar=0');
}

Open in new window


But that will only open the first URL (https://mycmssite.xyz/page_templates.aspx?page_ID=608)
And it opens it in a new window rather than a new tab. What should I do to open all of these at once in each new tab?
0
Comment
Question by:vituxa
11 Comments
 
LVL 9

Expert Comment

by:sognoct
Comment Utility
add jquery library and then :

$(function(){ // On DOM content ready...
    var urls = [];

    $('.yourlinks a').each(function(){
        urls.push(this.href);// Store the URLs from the links...

    });

    var multilink = $('<a href="#">Click here</a>');// Create a new link...
    multilink.click(function(){
        for (var url in urls) {
            window.open(url);// ...that opens each stored link in its own window when clicked...
        }
    });

    $('.yourlinks').replaceWith(multilink);// ...and replace the original HTML links with the new link.
});
0
 
LVL 13

Expert Comment

by:ansudhindra
Comment Utility
try like

window.open('https://mycmssite.xyz/page_templates.aspx?page_ID=608','_newtab', 'toolbar=0,location=0,menubar=0');
0
 
LVL 1

Author Comment

by:vituxa
Comment Utility
sognoct, can you please use three of my urls on this example? It isn't clear to me.
0
 
LVL 9

Expert Comment

by:sognoct
Comment Utility
$(function(){ // On DOM content ready...
    var urls = [];
        urls.push("https://mycmssite.xyz/page_templates.aspx?page_ID=608");
        urls.push("https://mycmssite.xyz/page_templates.aspx?page_ID=609");
        urls.push("https://mycmssite.xyz/page_templates.aspx?page_ID=610");

    var multilink = $('<a href="#">Click here</a>');// Create a new link...
    multilink.click(function(){
        for (var url in urls) {
            window.open(url);// ...that opens each stored link in its own window when clicked...
        }
    });

    $('.yourlinks').replaceWith(multilink);// ...and replace the original HTML links with the new link.
});
0
 
LVL 8

Expert Comment

by:RGRodgers
Comment Utility
My code fails the same way when the popup blocker interferes.  I happen to run the Google Toolbar and so I have to be logged in and have the popup blocker permitting popups for the page that is launching the new tabs.  My application is basically a menu that permits a selected series of tabs to be opened in one click.  One such example is as follows:

<br><a href="http://download.microsoft.com/" target="_blank"
        onclick="
            window.open(&quot;http://www.microsoft.com/&quot;);
            window.open(&quot;https://partner.microsoft.com/US/40096013&quot;);
            window.open(&quot;http://support.microsoft.com/&quot;);
            ">
        Partners</a>
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:vituxa
Comment Utility
sognoct, it doesn't work. It opens just the last url in the list. Can you please test it, make sure it works and give me a working example?
0
 
LVL 9

Accepted Solution

by:
sognoct earned 500 total points
Comment Utility
ok, this is a sample on the fly (I semplificated the code a lot)

When I started the page my chrome advised me that smart popup was activated, so I had to allow the page to open multiple pages!!! This because in every modern browser there is a smart control to prevent malware coder to create viral and annoying pages.
test.html
0
 
LVL 1

Author Comment

by:vituxa
Comment Utility
Thank you!!!
0
 
LVL 1

Author Comment

by:vituxa
Comment Utility
I am sorry I picked the wrong answer by accident as the best one. I wrote to the administrator about my error. Hopefully they get back to me soon and undo my error so that I can award the points to sognoct for the best answer.
0
 
LVL 9

Expert Comment

by:sognoct
Comment Utility
thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now