By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

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

P: n/a
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>

Sep 20 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

libsfan01 wrote:
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:

<script type="text/javascript">

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

--
Rob

Sep 20 '06 #2

P: n/a
libsfan01 wrote:
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.

Sep 20 '06 #3

P: n/a
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

Sep 20 '06 #4

P: n/a
libsfan01 wrote:
>If you want to navigate an IFRAME reliably assign the URL to the -
location - property of the window/frame object it contains.

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.

Sep 20 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.