why doesnt changing src with js work for iframes in safari?

L

libsfan01

hey this code wont work for my iframe in safari, i cant change the page
by changing the src with js:

<script language="javascript">
function loadcontent(page) {
document.getElementById('iframeid').src = page;
}
</script>


<iframe align="right" width="100%" src="links.php" id="content"
name="content" frameborder="0" style=" height:400px; border:none;
margin:0px; padding:0px;"></iframe>
 
R

RobG

libsfan01 said:
hey this code wont work for my iframe in safari, i cant change the page
by changing the src with js:

It works fine in Safari 2.0.4 (Mac OS X 10.4). Maybe you are testing
on 1.x?

<script language="javascript">

The language attribute is deprecated, type is required:
 
R

Richard Cornford

libsfan01 said:
hey this code wont work for my iframe in safari, i cant change the page
by changing the src with js:

<script language="javascript">
function loadcontent(page) {
document.getElementById('iframeid').src = page;
}
</script>

There is no reason to expect changing the - src - property of an IFRAME
to result in the navigation of the contained page as the HTML DOM
specification defines the property as 'the URL of the original contents
of the IFRAME', and changing the original contents has no clear
meaning.

If you want to navigate an IFRAME reliably assign the URL to the -
location - property of the window/frame object it contains.

Richard.
 
L

libsfan01

If you want to navigate an IFRAME reliably assign the URL to the -
location - property of the window/frame object it contains.

Richard.

Thanks for your help Richard, i had feleing it was something like that.
The changing SRC effort was really my first stab at doing it.

What would the syntax look like for the proper method?

regards

Marc
 
R

Richard Cornford

libsfan01 said:
Thanks for your help Richard, i had feleing it was something like that.
The changing SRC effort was really my first stab at doing it.

What would the syntax look like for the proper method?

<script type="text/javascript">
function loadcontent(url, frameName) {
frames[frameName].location = url;
}
</script>

Where the IFRAME should have a NAME attribute (possibly along with an
ID attribute, but they _must_ be identical) and it is the value of the
NAME attribute that is used to look up the window/frame object in the
current window's - frames - collection.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top