olsza7
05-14-2009, 08:31 PM
Hello,
I am using the following script (see below) to place a button on my page that generates several random links. It works very well but I would like the links to open in a new window (right now, it opens in the same window). What do I need to change in this script to achieve that? Thanks so much!
(part one of the script):
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function go_to(url) {
window.location=url;
}
function rand_link() {
var a;
a = 1+Math.round(Math.random()*3); // a = random number between 1-3
if (a==1) go_to("http://bgeffects.javascriptsource.com");
if (a==2) go_to("http://clocks.javascriptsource.com");
if (a==3) go_to("http://games.javascriptsource.com");
}
// End -->
</SCRIPT>
(part 2 of the script):
<BODY>
<CENTER>
<FORM NAME="myForm">
<INPUT TYPE="button" NAME="myButton" VALUE="Random link"
onClick="rand_link()">
</FORM>
</CENTER>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
I am using the following script (see below) to place a button on my page that generates several random links. It works very well but I would like the links to open in a new window (right now, it opens in the same window). What do I need to change in this script to achieve that? Thanks so much!
(part one of the script):
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function go_to(url) {
window.location=url;
}
function rand_link() {
var a;
a = 1+Math.round(Math.random()*3); // a = random number between 1-3
if (a==1) go_to("http://bgeffects.javascriptsource.com");
if (a==2) go_to("http://clocks.javascriptsource.com");
if (a==3) go_to("http://games.javascriptsource.com");
}
// End -->
</SCRIPT>
(part 2 of the script):
<BODY>
<CENTER>
<FORM NAME="myForm">
<INPUT TYPE="button" NAME="myButton" VALUE="Random link"
onClick="rand_link()">
</FORM>
</CENTER>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>