Forum Moderators: open

Message Too Old, No Replies

changing <iframe> src using script - netscape

all property iframes src

         

mess_iah

1:16 pm on May 22, 2003 (gmt 0)



Hi,

Im a newbie so be gentle with me. OK so heres my first question.

I'm using the following:


document.all.iFrame1.src = "mypage.html";

...to change the source of an iframe. I've since found out the the 'all' property is only supported by IE4 and above.

What would be a better way of doing this that NN would be ok with? (I've seen a similar post that mentions the use of the getElementbyID() method - would this be a better way of doing it?)

BlobFisk

2:06 pm on May 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, mess_iah!

getElementById will only work in DOM1 complint browsers (IE5+, Mozilla, Opera 5+ and Netscape 6+). You would write a script to accommodate all browser types.

However, a better approach may be to use the document.frames element and change the the URL by using the location method.

mess_iah

2:27 pm on May 22, 2003 (gmt 0)



thanks for the welcome!

Ok I tried this:

document.frames['iframe1'].location = "myPage.html";
and
document.frames[0].location = "myPage.html";

..and it works fine in IE5.5/6.0 but not NN6.2

..Im calling a user defined function where the parameter is the location to be loaded from an anchor i.e.

<a href="javascript:myfunction(mylocation);">

does this change things?

BlobFisk

2:36 pm on May 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm - if you are trying to change the location of the iFrame on a link, why not use target="frameName"?

mess_iah

2:44 pm on May 22, 2003 (gmt 0)



d'oh!

why do I always have to complicate matters :)

thanks guys