asharma
11-09-2004, 05:54 PM
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!
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!