AussieMega
04-17-2003, 08:17 AM
I'm using the following script to randomly generate a link to one of a number of assigned sites:
http://javascriptkit.com/script/cut1.shtml
The problem is, I want it to open in a new window, and I can't make it happen! And, for all of the searching I did to find a random link generator in the first place, none of them open in a new window. Thay all open in the same window, which doesn't help me!
Any help out there? I've posted the complete code at the bottom of this post.
Thanks much!
-AussieMega
<script>
<!--
/*
Random link button- By JavaScript Kit (http://javascriptkit.com)
Over 300+ free scripts!
This credit MUST stay intact for use
*/
//specify random links below. You can have as many as you want
var randomlinks=new Array()
randomlinks[0]="http://freewarejava.com"
randomlinks[1]="http://javascriptkit.com"
randomlinks[2]="http://dynamicdrive.com"
randomlinks[3]="http://cnn.com"
randomlinks[4]="http://www.geocities.com"
function randomlink(){
window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)]
}
//-->
</script>
<form>
<p><input type="button" name="B1" value="Random Link >>" onclick="randomlink()"></p> </form>
<!--Uncomment below to use a regular text link instead
<a href="javascript:randomlink()">Random Link</a>
-->
http://javascriptkit.com/script/cut1.shtml
The problem is, I want it to open in a new window, and I can't make it happen! And, for all of the searching I did to find a random link generator in the first place, none of them open in a new window. Thay all open in the same window, which doesn't help me!
Any help out there? I've posted the complete code at the bottom of this post.
Thanks much!
-AussieMega
<script>
<!--
/*
Random link button- By JavaScript Kit (http://javascriptkit.com)
Over 300+ free scripts!
This credit MUST stay intact for use
*/
//specify random links below. You can have as many as you want
var randomlinks=new Array()
randomlinks[0]="http://freewarejava.com"
randomlinks[1]="http://javascriptkit.com"
randomlinks[2]="http://dynamicdrive.com"
randomlinks[3]="http://cnn.com"
randomlinks[4]="http://www.geocities.com"
function randomlink(){
window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)]
}
//-->
</script>
<form>
<p><input type="button" name="B1" value="Random Link >>" onclick="randomlink()"></p> </form>
<!--Uncomment below to use a regular text link instead
<a href="javascript:randomlink()">Random Link</a>
-->