PDA

Click to See Complete Forum and Search --> : Auto Hyperlink Opener anyone??



andrewaesthetic
12-26-2006, 09:01 PM
Hi

Does anyone know of a script which opens up ALL the hyperlinks in the page to a new window at the same time? im talking without you having to click the links, the minute you go on the page it auto launches them.

a bit like one of them pop up prank sites, where you go onto it and your bombarded with pop ups.... but i need the script to work like "open all hyperlinks".. so it effects all hyperlinks on the page.... not "open hyperlink:www.web.com" .....

its not going to crash someones comp so dont worry, its for a gaming site, about 30 pop up windows.

1stbite
12-28-2006, 08:35 PM
Never seen or heard anyone doing this other tahn the obvious pop-up crap you get on cheap sites.

But I suppose it could be done using DOM and javascript.

use javascript to tranverse the DOM to pull all links from the page and pop them open in a new window by looping through them.

Using a text link to launch windows


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Pop open all links</title>
<script type="text/javascript" language="javascript">
function popWindows() {
if (!document.getElementsByTagName) return false;

var allAnchors = document.getElementsByTagName("a");

for (i=0; i<allAnchors.length; i++) {
var thisLink = allAnchors[i].getAttribute("href");
window.open(thisLink);
}
}
</script>
</head>

<body>
<a href="javascript:popWindows()">Click Here!</a>
<a href="test1.html">link</a>
<a href="test2.html">link</a>
<a href="test3.html">link</a>
<a href="test4.html">link</a>
<a href="test5.html">link</a>
</body>
</html>


launch all links on page load


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Pop open all links</title>
<script type="text/javascript" language="javascript">
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
function popWindows() {
if (!document.getElementsByTagName) return false;

var allAnchors = document.getElementsByTagName("a");

for (i=0; i<allAnchors.length; i++) {
var thisLink = allAnchors[i].getAttribute("href");
window.open(thisLink);
}
}
addLoadEvent(popWindows)
</script>
</head>

<body>
<a href="test1.html">link</a>
<a href="test2.html">link</a>
<a href="test3.html">link</a>
<a href="test4.html">link</a>
<a href="test5.html">link</a>
</body>
</html>


I would be careful using such a script though, I for one would hate any site launching multiple windows without my say so and would probably never use the site again if they did.

Frets
12-28-2006, 10:06 PM
That's my setiment as well.

I would strongly suggest not showcasing that pop up site in our forums.
It could lead to insta ban.

Even when people have pop up blockers They get pissed with the pop up blocker notice.

Chris_Seahorn
12-29-2006, 01:11 AM
Wow. This is seen as user friendly to the site admins?.....really? I'd tend to be irritated by 30 embedded ads but 30 auto fired popups would be the quickest way to ensure I never return to play a single game once my popup blocker stopped smoking.

This example should be added to the sticky under "Things you should never do".

andrewaesthetic
12-29-2006, 07:43 AM
Never seen or heard anyone doing this other tahn the obvious pop-up crap you get on cheap sites.

But I suppose it could be done using DOM and javascript.

use javascript to tranverse the DOM to pull all links from the page and pop them open in a new window by looping through them.

Using a text link to launch windows


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Pop open all links</title>
<script type="text/javascript" language="javascript">
function popWindows() {
if (!document.getElementsByTagName) return false;

var allAnchors = document.getElementsByTagName("a");

for (i=0; i<allAnchors.length; i++) {
var thisLink = allAnchors[i].getAttribute("href");
window.open(thisLink);
}
}
</script>
</head>

<body>
<a href="javascript:popWindows()">Click Here!</a>
<a href="test1.html">link</a>
<a href="test2.html">link</a>
<a href="test3.html">link</a>
<a href="test4.html">link</a>
<a href="test5.html">link</a>
</body>
</html>


launch all links on page load


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Pop open all links</title>
<script type="text/javascript" language="javascript">
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
function popWindows() {
if (!document.getElementsByTagName) return false;

var allAnchors = document.getElementsByTagName("a");

for (i=0; i<allAnchors.length; i++) {
var thisLink = allAnchors[i].getAttribute("href");
window.open(thisLink);
}
}
addLoadEvent(popWindows)
</script>
</head>

<body>
<a href="test1.html">link</a>
<a href="test2.html">link</a>
<a href="test3.html">link</a>
<a href="test4.html">link</a>
<a href="test5.html">link</a>
</body>
</html>


I would be careful using such a script though, I for one would hate any site launching multiple windows without my say so and would probably never use the site again if they did.

hey

its not being used for a bad reason, so dont worry lol.

thanks it works great!

Chris_Seahorn
12-29-2006, 02:07 PM
its not being used for a bad reason, so dont worry lol.


There is no such thing as a "good reason" to autofire 30 popups. There may be to you who is firing them but not to the ones being fired upon. I'd sincerely like to see that script pasted above completely disappear. The web is already overrun with advertisements and that sitting there for everyone with this mindset to use will not help the situation for the general population simply trying to navigate without these types of invasive attempts to force things upon them. To me it's no different than teaching a wannabe mail spammer to mail bomb with a provided script and just as foul in it's reason for existing.