 |
| Javascript General Javascript discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 16th, 2004, 09:19 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
IFRAME Issue
Hi,
I am using the following code to change the IFRAME Source dynamically.
ifrObj.location.href = "filename.asp"
This code seems to work fine on IE 6.0 with or without SP1.
But strangely, it works only once on IE 5.0. That is, consider this code is written for a button click event. Then, this frame changes it's content correcly on the first click. But on the next click there does not seem anything happening.
regds,
Babloo
|
|

March 16th, 2004, 04:12 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Can you please post the code you are using?
----------
---Snib---
----------
<><
|
|

March 17th, 2004, 12:47 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here is the sample code.
<html>
...
<script>
function fnChangeTo(strFileName){
ifrBodyArea.location.href = strFileName
}
</script>
<body>
<input type="button" onclick="javascript:fnChangeTo('t1.asp')" value="t1">
<input type="button" onclick="javascript:fnChangeTo('t2.asp')" value="t2">
<input type="button" onclick="javascript:fnChangeTo('t3.asp')" value="t3">
<div class="subContentArea">
<iframe id="ifrBodyArea" frameborder="0" class="subContentAreaForIFrame"></iframe>
</div>
</body>
...
</html>
Actually on Body Load I call fnChangeTo('t1.asp'). This works fine in both IE 5.0 and IE 6.0.
But then when I click on any of those buttons, in IE 6.0 it changes properly. But in IE 5.0 it does not change the pages. But strangly if I give an alert box after this line, the page changes.
Seems to me like a browser issue. Is there a workaround?
|
|

March 17th, 2004, 02:07 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
Isnt this question repetitive?!? ( http://p2p.wrox.com/topic.asp?TOPIC_ID=11024)
Anyway use window.frames[0].location.href = strFileName; instead of [u]ifrBodyArea.location.href = strFileName</u>.
Ive tested this on IE v6.0, Opera, Netscape & Mozila!!!
Always:),
Hovik Melkomian.
|
|

March 17th, 2004, 02:24 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi melvik,
Thanks for the code. Now consider i have pages with say 5 IFRAMES, how do i refer to each of them,
is it,
window.frames[0].location.href
window.frames[1].location.href
window.frames[2].location.href
....
and the order is the one same I have given it in BODY tag?
|
|

March 17th, 2004, 02:44 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
Another approach is to use:
document.getElementById('ifrBodyArea').src = 'path/to/file';
: )
Rich
:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
|
|

March 17th, 2004, 03:26 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
Yes the order is as u put it in ur page!
but if u think that ur IFrames will not be fix & might be change in order & ... use
Code:
document.getElementById('ifrBodyArea').src
as dear quesadilla5 mentioned!
Always:),
Hovik Melkomian.
|
|

March 17th, 2004, 05:25 AM
|
|
Authorized User
|
|
Join Date: Nov 2003
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi all,
Thanks for the replys.
document.getElementById('ifrBodyArea').src behaves wierd in IE 5.0, especially if there are more that 2 parent IFRAMAES. I would accept melvik's previous answer,
window.frames[0].location.href as this works well in both IE 5.0 and IE 6.0
Thanks,
Babloo
|
|
 |