Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 16th, 2004, 09:19 AM
Authorized User
 
Join Date: Nov 2003
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

Reply With Quote
  #2 (permalink)  
Old March 16th, 2004, 04:12 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Can you please post the code you are using?

----------
---Snib---
----------

<><
Reply With Quote
  #3 (permalink)  
Old March 17th, 2004, 12:47 AM
Authorized User
 
Join Date: Nov 2003
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?
Reply With Quote
  #4 (permalink)  
Old March 17th, 2004, 02:07 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

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.
Reply With Quote
  #5 (permalink)  
Old March 17th, 2004, 02:24 AM
Authorized User
 
Join Date: Nov 2003
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?



Reply With Quote
  #6 (permalink)  
Old March 17th, 2004, 02:44 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Another approach is to use:
document.getElementById('ifrBodyArea').src = 'path/to/file';

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
  #7 (permalink)  
Old March 17th, 2004, 03:26 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

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.
Reply With Quote
  #8 (permalink)  
Old March 17th, 2004, 05:25 AM
Authorized User
 
Join Date: Nov 2003
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
iFrame vs. cookie issue. leouser PHP How-To 1 November 21st, 2007 03:34 AM
values from one iframe to another iframe URGENT raaj Beginning PHP 2 February 27th, 2007 12:19 PM
iFrame fyp4135 ASP.NET 2.0 Basics 0 October 5th, 2006 11:32 AM
iframe help splinterz HTML Code Clinic 12 April 13th, 2005 01:42 AM
iframe...or a better way? stacy HTML Code Clinic 4 September 4th, 2004 11:04 AM



All times are GMT -4. The time now is 01:26 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.