problem with JavaScript in IE

V

VAXman-

I have been trying to copy a DIV in an IFRAME to the TOP DOCUMENT.

The code does the following

iframeDIV = document.getElementById('div_in_iframe');

var clonedDIV = iframeDIV.cloneNode(true);


It then sets various attributes of clonedDIV.

The last thing it does is:

top.document.body.appendChild(clonedDIV);


This works in FF and Safari but it fails in IE. IE doesn't seem to
like the last statement. Why?
 
D

Dmitry Kulinich

if (nodes[j].outerHTML.indexOf('IFRAME') == -1){

control = nodes[j].cloneNode(true);

}

else {

control = nodes[j].cloneNode(false);

control.insertAdjacentHTML('afterBegin', nodes[j].innerHTML);

}
 
V

VAXman-

if (nodes[j].outerHTML.indexOf('IFRAME') == -1){

control = nodes[j].cloneNode(true);

}

else {

control = nodes[j].cloneNode(false);

control.insertAdjacentHTML('afterBegin', nodes[j].innerHTML);

}

I have been trying to copy a DIV in an IFRAME to the TOP DOCUMENT.

The code does the following

iframeDIV = document.getElementById('div_in_iframe');

var clonedDIV = iframeDIV.cloneNode(true);


It then sets various attributes of clonedDIV.

The last thing it does is:

top.document.body.appendChild(clonedDIV);


This works in FF and Safari but it fails in IE. IE doesn't seem to
like the last statement. Why?

Could you explain this code you've provided and how I would insert it
in place of the top.document.body.appendChild(clonedDIV); in my code.

BTW, I found that using parent instead of top made M$IE happier. I no
longer get M$IE coughing up an error on the

parent.document.body.appendChild(clonedDIV);

but it still doesn't display the clonedDIV.
 
R

RobG

Please don't top-post, reply below trimmed quotes. Posting order
restored.
I have been trying to copy a DIV in an IFRAME to the TOP DOCUMENT.
The code does the following
iframeDIV = document.getElementById('div_in_iframe');
var clonedDIV = iframeDIV.cloneNode(true);
It then sets various attributes of clonedDIV.
The last thing it does is:
top.document.body.appendChild(clonedDIV);
This works in FF and Safari but it fails in IE. IE doesn't seem to
like the last statement. Why?

if (nodes[j].outerHTML.indexOf('IFRAME') == -1){

Given that a good many browsers don't support IE's proprietary
outerHTML property, test for support before attempting to use it.

control = nodes[j].cloneNode(true);

}

else {

control = nodes[j].cloneNode(false);

control.insertAdjacentHTML('afterBegin', nodes[j].innerHTML);

The same for insertAdjacentHTML.
 
V

VAXman-

{...snip..}
Could you explain this code you've provided and how I would insert it
in place of the top.document.body.appendChild(clonedDIV); in my code.

BTW, I found that using parent instead of top made M$IE happier. I no
longer get M$IE coughing up an error on the

parent.document.body.appendChild(clonedDIV);

but it still doesn't display the clonedDIV.

Nevermind. I figured it out. Stupid typo when I went to follow the
suggested code. Strangely, I'd looked many of the things referenced
but decided code up the page and then go back later for M$IE support.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top