Forum Moderators: open

Message Too Old, No Replies

Can't get link to open in a new window

         

outdoorxtreme1

11:36 pm on Jan 8, 2006 (gmt 0)

10+ Year Member



I am trying to get the link part of this script to open in a target="_blank" window. Can anyone help me?

<!--
var currentdate = 0
var theranlink = " "
var core = 0

function StringArray (n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' '
}
}
//specify random images below.
image = new StringArray(7)
image[0]="/images/random_trip_images/DSC00669small.jpg"
image="/images/random_trip_images/DSC02646small.jpg"
image[2]="/images/random_trip_images/DSC01345small.jpg"
image[3]="/images/random_trip_images/DSC01437small.jpg"
image[4]="/images/random_trip_images/DSC02160small.jpg"
image[5]="/images/random_trip_images/DSC01112small.jpg"
image[6]="/images/random_trip_images/DSC02628small.jpg"

var ran = 60/image.length

//specify random link below.
link = new StringArray(7)
link[0] = 'http://www.example.com/gallery2/v/ATV+Leavittsburg+Sandpits+5-15-02/slideshow.html'
link[1] = 'http://www.example.com/gallery2/v/YAKPACKING+Clarion+River+10-15-04+to+10-17-04/slideshow.html'
link[2] = 'http://www.example.com/gallery2/v/BACKPACKING+Clarion+River+Trail+3-21-03+to+3-23-03/slideshow.html'
link[3] = 'http://www.example.com/gallery2/v/BACKPACKING+Clarion+River+Trail+4-25-03+to+4-27-03/slideshow.html'
link[4] = 'http://www.example.com/gallery2/v/BACKPACKING+Minister+Creek+3-26-04+to+3-28-04/slideshow.html'
link[5] = 'http://www.example.com/gallery2/v/BACKPACKING+Clarion+River+Trail+9-27-02+to+9-29-02/slideshow.html'
link[6] = 'http://www.example.com/gallery2/v/KAYAKING+Little+Beaver+Creek+10-9-04/slideshow.html'

var ran = 60/link.length

function ranlink() {
currentdate = new Date()
core = currentdate.getSeconds()
adcore = Math.floor(core/ran)
core = adcore
theranlink = link[core]
self.location = theranlink
}

function ranimage() {
currentdate = new Date()
core = currentdate.getSeconds()
core = Math.floor(core/ran)
return(image[core])
}

document.write("<div align=center><a href='javascript:ranlink(); '><img src='" +ranimage()+ "' width=120 height=90 border=3><\/a><\/div>")

var currentdate = 0
var core = 0

function StringArray (n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' '
}
}
//specify random images below.
title = new StringArray(7)
title[0]="<b>ATV<\/b><br>Sandpits<br>May 2002"
title[1]="<b>Yakpacking<\/b><br>Clarion River<br>October 2004"
title[2]="<b>Backpacking<\/b><br>Clarion River<br>March 2003"
title[3]="<b>Backpacking<\/b><br>Clarion River<br>April 2003"
title[4]="<b>Backpacking<\/b><br>Clarion River,<br>Loleta,<br>Minister Creek<br>March 2004"
title[5]="<b>Backpacking<\/b><br>Clarion River<br>September 2002"
title[6]="<b>Kayaking<\/b><br>Little Beaver Creek<br>October 2004"

var ran = 60/title.length

function rantitle() {
currentdate = new Date()
core = currentdate.getSeconds()
core = Math.floor(core/ran)
return(title[core])
}
document.write("<div align=center>" +rantitle()+ "<\/div>")
//-->

[1][edited by: tedster at 12:12 am (utc) on Jan. 9, 2006]
[edit reason] use example.com [/edit]

DrDoc

7:59 am on Jan 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Instead of
self.location.href
you want to use a
window.open
function.

outdoorxtreme1

6:28 pm on Jan 10, 2006 (gmt 0)

10+ Year Member



I changed self.location = theranlink

to window.open = theranlink

That didn't work. Any other suggestions or did I do something wrong?

Bernard Marx

9:18 pm on Jan 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



newWindowRef = open(theranlink, "_window_name_","_window_attributes_");

Details:
[devguru.com...]

BTW, what's with all the creating StringArray objects and filling them with spaces?
It all seems like a waste of bytes & microseconds.

Bernard Marx

9:52 pm on Jan 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



image[0]="/images/random_trip_images/DSC00669small.jpg" 
image[blue][b][1][/b][/blue]="/images/random_trip_images/DSC02646small.jpg"
image[2]="/images/random_trip_images/DSC01345small.jpg"