Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing URL in <A HREF>

Status
Not open for further replies.

ReWeFe

MIS
Mar 30, 2003
25
US
I have a hyperlinked image ("button") in a MenuFrame.

This link w/image, in my frame is defined like this:
<a id=&quot;link&quot; href=&quot; target=&quot;_blank&quot;><img name=&quot;button&quot; src=&quot;Picture1.jpg&quot;></a>


On my main page I have an array of my pictures with corresponding links, in the header like this:

var objects=2
var o=new Array()
var l=new Array()

o[1]=&quot;Picture1.jpg&quot;
l[1]=&quot;o[2]=&quot;Picture2.jpg&quot;
l[2]=&quot;

I want to chose a random image when this main page is loaded, actually I want the image and link to change every few minutes, but that another story. This is how I chose a random image and link:

Today=new Date()

object=Math.round(Today/86400000) % objects+1

parent.MenuFrame.document.images['button'].src=o[object]

parent.MenuFrame.document.links['link'].href=l[object]


The above works PERFECT in Netscape and Opera, but Internet Explorer gives me an error. If I then change my reference to the link, to an absolute instead of named like this:
parent.MenuFrame.document.links[10].href=l[object]

IE gives me no errors, but it does NOT change the link.

What am I doing wrong here?
 
What if you had your script set a variable...

Today=new Date()
object=Math.round(Today/86400000) % objects+1
parent.MenuFrame.document.images['button'].src=o[object]
parent.MenuFrame.imgLink=l[object]

Then have your link just point to that variable...

<a href=&quot;javascript:window.open(imgLink,'_blank')&quot;><img name=&quot;button&quot; src=&quot;Picture1.jpg&quot;></a>

Also, &quot;link&quot;, &quot;button&quot;, and &quot;object&quot; are all keywords. You may want to consider renaming them.

Adam
while(woman.width>woman.height && wallet.value>0){beer++;vision.blur()};
 
Hmm, well the link now changes but my menuframe goes blank (grey) when I click the image, and it's showing just the text:

[object]


By the way, I changed all the keywords you mentioned just to be sure.

I guess I don't understand this, but is variables recognized across diferent frames? Because the variable is &quot;imgLink&quot; is given a value on the main frame and then called in the menuframe as per your example.

If I can't get this to work, maybe I'll just name a table cell on my frame on write out dynamicaly the link and image.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top