Click to See Complete Forum and Search --> : How to Open page in New Window?


netsavage
03-05-2004, 02:18 PM
Hello

I need help in modifiing this banner rotation script so that the links open in a new window.

<td><script language="Javascript">
<!--
var core = 0;

link = new Array(
"URL",
"URL"
);

image = new Array(
"IMAGE",
"IMAGE"
);

text = new Array(
"TEXT",
"TEXT"
);

var time = new Date();
var core = time.getSeconds() % image.length;
var ranlink = link[core];
var ranimage = image[core];
var rantext = text[core];

document.write('<a href=\"' +ranlink+ '\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a> ');

//-->
</SCRIPT></td>

Please help!

Thanks

jaegernaut
03-05-2004, 02:25 PM
Change this line:
document.write('<a href=\"' +ranlink+ '\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a> ');

To this:
document.write('<a href=\"' +ranlink+ '\" target=\"_blank\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a> ');

netsavage
03-05-2004, 02:32 PM
Thank you so much.

jaegernaut
03-05-2004, 02:36 PM
You're welcome. Happy to help.

steelersfan88
03-05-2004, 03:54 PM
Just a suggestion, this is probably better:<script type="text/javascript">

var images = new Array
// where text is the images text, link is its link, and image is the picture
images[0] = {text:'TEXT1',link:'URL1',image:'IMAGE1'}
images[1] = {text:'TEXT2',link:'URL2',image:'IMAGE2'}

var time = new Date();
var core = time.getSeconds() % images.length;

var ranlink = images[core].link
var ranimage = images[core].image
var rantext = images[core].text

document.write('<a href=\"' +ranlink+ '\" target="_blank"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a> ');

</SCRIPT>