Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-09-2004, 05:54 PM   PM User | #1
asharma
New to the CF scene

 
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
asharma is an unknown quantity at this point
Replacing div contents in IE from hidden IFRAME

Hi -

Sorry - I'm probably being very thick here, but I just don't seem to be able to get IE (version 6) to remove child nodes of a div and replace it with a div from some content in a hidden iframe.

It seems to work perfectly well in Firefox version 1.0 and I was hoping someone out there may be able to help.

I have the following code:

<html>
<head>
<title>Test - Create an iframe</title>

<script language="Javascript" type="text/javascript">

document.domain='london.edu';

function makeFrame() {

notesFrame = document.getElementById('remotecontent');

notesFrame.setAttribute("src", "http://forum.london.edu/lbsbiogs_redesign.nsf/httpBiographySearch?SearchView&Query=FIELD+SubjectArea=Accounting");
notesFrame.setAttribute("style", "width: 200px; height: 200px; frameborder: 0px;");

contentdiv = document.getElementById('content');

contentdiv.appendChild(notesFrame);


}


function loaded() {

iframecontent = document.getElementById("remotecontent");

if(iframecontent.contentDocument != null) {

alert("found iframe content");
documentcontent = iframecontent.contentDocument;

documentdiv = documentcontent.getElementById('dominocontent');
if(documentdiv != null) {
alert(documentdiv);

contentdiv = document.getElementById('content');
alert(contentdiv);

contentdiv.appendChild(documentdiv);
contentdiv.removeChild('remotecontent');
}
}
}

</script>
</head>
<body>
<a href="#" onMouseDown="makeFrame()">Click to make iframe</a>
<div id="content">
</div>
<iframe id="remotecontent" name="remotecontent" width="200px" height="200px" frameborder="0px" onLoad="loaded()">
</iframe>
</body>
</html>


This is simply a test file to get working what I need to get working.

To summarise, I do the following:

- grab the iframe remotecontent
- set the src and display properties
- attach the iframe to the parent div (so it can be located in the document tree)

Once the frame loads, the onload event calls loaded() which:

- grabs the iframe
- gets the dominocontent node (which is the one I want to copy)
- grabs a reference to the content div which will be the content's parent
- removes the iframe

This seems to work fine in Firefox (apart from removing the iframe at the very end) but won't work in IE.

Can anyone tell me where I am going wrong?

I'm actually more used to server side development and niavely expected IE to obey the DOM standard!
asharma is offline   Reply With Quote
Old 11-09-2004, 06:46 PM   PM User | #2
Willy Duitt
Banned

 
Join Date: Sep 2003
Posts: 3,620
Thanks: 0
Thanked 0 Times in 0 Posts
Willy Duitt is an unknown quantity at this point
Quote:
Originally Posted by asharma
Hi -
....and niavely expected IE to obey the DOM standard!
Don't jump on the IE bashing band wagon to quick...
(besides, I checked this with Firefox also and it does nothing but initially load an empty iframe without a source but nothing suggests that your script recognizes the source code of the iframe... It only recognizes it is there on the page)

There is nothing in your codes that suggest the use of the DOM to retrieve the iframes source... Where's the reference to any nodes? tags?

All I see is references to several elements ( division, iframe) and in the context you are using them you are referencing them as objects... Not what they contain....

.....Willy
Willy Duitt is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:48 AM.


Advertisement
Log in to turn off these ads.