Open multiple links with one click?

I maintain a simple internal web page where I work. I know basic html, but not much else about web programming. One thing that would be very useful to me would be the ability to open multiple web pages, in separate windows, with one mouse click. Is this possible without a lot of programming knowledge?

That depends on what you mean by “a lot of programming knowledge.” The following simple Javascript will open multiple files in new windows.



<a href="#" onClick="window.open('http://flex727.com/foo.html'); window.open('http://flex727.com/bar.html'); window.open('http://flex727.com/baz.html');">clickity click</a>.


Should be self-explanatory. Modify as you see fit.

Or another, related method:

enter something like the following in the header:

<script language = “javascript”>
function openWindows(){
window.open(“http://www.aURL.com”);
window.open(“http://www.anotherURL.com”);
window.open(“http://www.aThirdURL.com”);
}
</script>

Then your link looks like this:

<a href = “javascript:openWindows()”>linkity-link</a>

Gakk! Ignore the “embarassment” smiley; that’s supposed to be “javascript<colon>openWindows()”

Personally, I prefer to use external scripts. Save the script above as a separate file, titled, say, windows.js in a folder named, say, scripts. This way all your scripts are in one place. Put this line in the header:

<script langauge = “javascript” type = “text/javascript” src = “scripts/windows.js”></script>

The link will still look the same. I prefer external scripts because this way I can use the same javascript functions on multiple pages with one line of code per page, and if I want to make changes, I only have to make changes in one place.

Thanks! Do I need something in the page header for this (as mentioned in Ninja Pizza Guy’s post)?

You only need a script or a pointer to a script in the header if you’re not going to have the script in-line on the page. So, no, you don’t need a header entry if you use friedo’s method.

Note that these count as “popups”, so it won’t work for people with popup blockers enabled. Your popups are certainly for a good reason, but they’re very similar in function to the obnoxious stuff advertisers do, so people suppressing the obnoxious stuff will end up suppressing your stuff too.

Porn sites use this method.

Are you sure you want to do this? Your site visitors might think you figured out how to do this by visiting porn sites. Nothing wrong with that, of course, but do you want your web visitors to think that?

Popup blockers generally only block window opens that occur as a result of loading a page, not clicking a link. Web applications use the latter sort all the time; it is not seen as pr0n-like. (Although opening three at a time does seem a bit much.)

They may count as popups, but they aren’t treated as popups, at least not on my setup. I’ve got a multi-page site I run for my own use and almost every link on every page uses JavaScript to open in new windows. I use Safari, Shiira and Firefox, all set to block popups, and they still work on all three browsers.

Tried this and it is working well. I am opening 15(!) windows with one mouse click and no problems with pop block (at least with my computer).

What I’m doing is simplifying a process we go through each day. I work for a semiconductor manufacturing company in a wafer fab. Each day we review SPC charts for certain processes in our daily ops meeting. To simplify things, I set up an intranet web page with links to all the charts. It was getting to be a pain clicking on each of 15 links each morning. Now I’ll be able to do one click, all 15 pages open, and we get on with business much more efficiently.

Thanks to all for the help.

Well, for what it’s worth, I just verified that friedo’s code brings up the “popup blocked” bar in IE SP2 on windows XP.

If what you’re doing is a popup, expect at least some popup blockers to thwart it.