1.

Solve : Opening two sites with one click (within a div tag)?

Answer» This is how you do it without the div tag:

Code: [SELECT]<a href="http://www.example.org" onclick="window.open('http://www.google.com','newwin');">click me</a>


but this is how I'm trying to do it with a div tag so that my page containing a randomizer refreshes:

Code: [Select]<div align="center">
<SCRIPT language="JavaScript">
<!--
images = new Array(2);

images[0] = "<a href='http://www.HOMEPAGE.com/' onclick='window.open('http://www.RANDOMPAGE1.com','newwin');'>click here to view<br>A RANDOM PAGE</a>"; 

images[1] = "<a href = 'http://www.HOMEPAGE.com/' onclick='window.open('http://www.RANDOMPAGE2.com','newwin');'>click here to view<br>A RANDOM PAGE</a>";


index = Math.floor(Math.random() * images.length);
document.write(images[index]);
// -->
</script></div>


Obviously, the only difference is the single-quote VS. the double-quote, but the array won't work if I add the double-quotation marks. ANY help would be Amazing!!! Thanks!OK, so I've done some more research, and it might have something to do with adding reverse BACKSLASHES??? \\\\\

Am I on the right track? And isn't a reverse backslash just a slash?  :-/ Quote
images[0] = "<a href='http://www.HOMEPAGE.com/' onclick='window.open('http://www.RANDOMPAGE1.com','newwin');'>click here to view
A RANDOM PAGE[/url]"; 

images[1] = "<a href = 'http://www.HOMEPAGE.com/' onclick='window.open('http://www.RANDOMPAGE2.com','newwin');'>click here to view
A RANDOM PAGE[/url]";
Yes, adding a backslash is called an ESCAPE character.

Code: [Select]images[0] = "<a href=\"http://www.HOMEPAGE.com/\" onclick=\"window.open('http://www.RANDOMPAGE1.com','newwin');\">click here to view<br>A RANDOM PAGE</a>"; 

images[1] = "<a href=\"http://www.HOMEPAGE.com/\" onclick=\"window.open('http://www.RANDOMPAGE2.com','newwin');\">click here to view<br>A RANDOM PAGE</a>";
Thank you!No problem.


Discussion

No Comment Found