PDA

View Full Version : Need Help adding Open Window to Random Link Script


SWC76801
11-26-2005, 06:42 PM
I'm using the code for a Random Image Link Script- By JavaScript Kit(http://www.javascriptkit.com). Even thought I'm a novice with JavaScript, I have been able to implement the code without any problems. I'm impressed with how well it works.

I want to have the new link open in a new window. To do this I've tried to add the target="_blank" attribute to the code, but have totally failed with all of my attempts.. I think the appropriate line of code is:

document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')

I would also like to add an alt tag to the link -- something like "Click Here For More Information", but haven't attempted to make this addition until I get the new window tag to work.

I would appreciate it very much if someone could show me what I'm overlooking with this.

Thanks in advance for your help!

_Aerospace_Eng_
11-26-2005, 06:56 PM
Since you haven't showed us ALL of YOUR code we can only guess, try this
document.write('<a href="'+imagelinks[ry]+'" target="_blank" title="Click Here For More Information"><img src="'+myimages[ry]+'" style="border:0;" alt="Click Here For More Information"></a>')

Mr J
11-26-2005, 06:57 PM
This should work

document.write('<a href="'+imagelinks[ry]+'" target="_blank"><img src="'+imagelinks[ry]+'" alt="Click Here For More Information" border=0></a>')

SWC76801
11-27-2005, 02:53 AM
This solved the problem. And as an added plus, I think I understand how the code works and why it was written this way. I should be able to handle something like this in the future.