Click to See Complete Forum and Search --> : Link open in new window?


GamerBlake
07-06-2003, 04:12 PM
Here's some code I'm using on my site that loads a picture with a random link. What I'm wondering is if anyone knows what I need to add (and where) to get the links to open in a new window?


First part in head:

<SCRIPT>
<!-- Activate Cloaking Device

// Set to number of image/links available.
var number=6;
// Becomes generated random number.
var random_number=0;

// Random number generating.
today=new Date();
jran=today.getTime();
ia=9301;
ic=49297;
im=233280;
jran = (jran*ia+ic) % im;
random_number=Math.ceil( (jran/(im*1.0)) *number);

// Create and define arrays.
image = new Array(6);
link = new Array(6);

image[0] = "http://n-chicken.net/images/insanity_animation.gif";
link[0] = "http://n-chicken.net/animation";
image[1] = "http://n-chicken.net/images/insanity_dot.gif";
link[1] = "http://n-chicken.net/animation/dot.gif";
image[2] = "http://n-chicken.net/images/insanity_sillyfun.gif";
link[2] = "http://n-chicken.net/animation/sillyfunextended.swf";
image[3] = "http://n-chicken.net/images/insanity_starwars.jpg";
link[3] = "http://n-chicken.net/fanfiction/starwars.shtml";
image[4] = "http://n-chicken.net/images/insanity_swimming.jpg";
link[4] = "http://n-chicken.net/stuff/swimming.shtml";
image[5] = "http://n-chicken.net/images/insanity_waterbuffalo.jpg";
link[5] = "http://n-chicken.net/stuff/waterbuffalo.shtml";

// Called by View Source button - displays source of file.
function viewSource()
{
var current_url="";
current_url=document.location;
window.location="view-source:"+current_url;
}

// Function for viewing source code/saving file.
function WinOpen()
{
alert('\nPage will load to full screen.\n\nUse View/Document Source
from menu bar to view source.\n\nClose new window to return to this page. ');
window.open("js-rnd3.htm","DisplayWindow","menubar=yes,scrollbars=yes");
window.open("js-rnd3.htm","DisplayWindow","menubar=yes,scrollbars=yes"); // double for Macs
}

// Deactivate Cloaking -->
</SCRIPT>






Second part placed in body of doc:

<SCRIPT>
<!-- Activate Cloaking Device
// Open document for writing.
document.open();

// This is the line that displays the appropriate image/link.
document.write("<CENTER><A HREF='"+link[random_number-1]+"'>
<IMG SRC="+image[random_number-1]+" WIDTH=121 HEIGHT=242 BORDER=0></A><BR><BR>");

// Close document.
//document.close();
// Deactivate Cloaking -->
</SCRIPT>

David Harrison
07-06-2003, 04:22 PM
inside the a tag in the document.write add target='_blank'

GamerBlake
07-06-2003, 10:43 PM
Thank you muchly.