# Open multiple links with one click?

**URL:** https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970
**Category:** Factual Questions
**Created:** [March 4, 2005, 9:08pm UTC](https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970 "2005-03-04T21:08:55Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![flex727](https://avatars.discourse-cdn.com/v4/letter/f/258eb7/32.png) [@flex727](https://boards.straightdope.com/u/flex727)
#### Post date: [March 4, 2005, 9:08pm UTC](https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970/1 "2005-03-04T21:08:55Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)
#### Post date: [March 5, 2005, 2:01am UTC](https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970/2 "2005-03-05T02:01:07Z")

</div>

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

```auto

<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.

---

<div class="post-metadata">

### Author: ![Ninja\_Pizza\_Guy](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@Ninja\_Pizza\_Guy](https://boards.straightdope.com/u/Ninja_Pizza_Guy)
#### Post date: [March 5, 2005, 2:57pm UTC](https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970/3 "2005-03-05T14:57:45Z")

</div>

Or another, related method:

enter something like the following in the header:

\<script language = “javascript”\>  
function openWindows(){  
window.open(“[http://www.aURL.com](http://www.aURL.com)”);  
window.open(“[http://www.anotherURL.com](http://www.anotherURL.com)”);  
window.open(“[http://www.aThirdURL.com](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.

---

<div class="post-metadata">

### Author: ![flex727](https://avatars.discourse-cdn.com/v4/letter/f/258eb7/32.png) [@flex727](https://boards.straightdope.com/u/flex727)
#### Post date: [March 5, 2005, 8:08pm UTC](https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970/4 "2005-03-05T20:08:56Z")

</div>

> [@friedo](#):
>
> That depends on what you mean by “a lot of programming knowledge.” The following simple Javascript will open multiple files in new windows.
> 
> ```auto
> 
> <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.

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

---

<div class="post-metadata">

### Author: ![Ninja\_Pizza\_Guy](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@Ninja\_Pizza\_Guy](https://boards.straightdope.com/u/Ninja_Pizza_Guy)
#### Post date: [March 5, 2005, 8:20pm UTC](https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970/5 "2005-03-05T20:20:29Z")

</div>

> [@flex727](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![spinky](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@spinky](https://boards.straightdope.com/u/spinky)
#### Post date: [March 5, 2005, 8:44pm UTC](https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970/6 "2005-03-05T20:44:29Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Duckster](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/duckster/32/1244_2.png) [@Duckster](https://boards.straightdope.com/u/Duckster)
#### Post date: [March 5, 2005, 8:49pm UTC](https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970/7 "2005-03-05T20:49:46Z")

</div>

> [@ntucker](#):
>
> 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?

---

<div class="post-metadata">

### Author: ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)
#### Post date: [March 5, 2005, 8:52pm UTC](https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970/8 "2005-03-05T20:52:03Z")

</div>

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.)

---

<div class="post-metadata">

### Author: ![Ninja\_Pizza\_Guy](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@Ninja\_Pizza\_Guy](https://boards.straightdope.com/u/Ninja_Pizza_Guy)
#### Post date: [March 5, 2005, 10:46pm UTC](https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970/9 "2005-03-05T22:46:32Z")

</div>

> [@ntucker](#):
>
> 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.

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.

---

<div class="post-metadata">

### Author: ![flex727](https://avatars.discourse-cdn.com/v4/letter/f/258eb7/32.png) [@flex727](https://boards.straightdope.com/u/flex727)
#### Post date: [March 6, 2005, 7:55pm UTC](https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970/10 "2005-03-06T19:55:00Z")

</div>

> [@friedo](#):
>
> That depends on what you mean by “a lot of programming knowledge.” The following simple Javascript will open multiple files in new windows.
> 
> ```auto
> 
> <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.

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.

---

<div class="post-metadata">

### Author: ![spinky](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@spinky](https://boards.straightdope.com/u/spinky)
#### Post date: [March 6, 2005, 11:52pm UTC](https://boards.straightdope.com/t/open-multiple-links-with-one-click/292970/11 "2005-03-06T23:52:05Z")

</div>

> [@Ninja Pizza Guy](#):
>
> 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.

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.
