ie appendChild problem.
I have a 2 divs, one div has an iframe showing a pdf, i want to move the iframe from one div and place it in the other.
the code is as follows
var div1 = document.getElementById("div1");
var div2 = document.getElementById("div2");
var if = document.getElementById("pdf1");
div2.style.display = "block";
div1.style.display = "none";
<div id="div2" style="border:3px solid red;margin-bottom:50px;display:none">
<button name="swapSrc" onclick="swapSrc();">Swap</button>
<div id="div1" style="border:1px solid blue">
<iframe id="pdf1" src="http://localhost/testPage/sample.pdf" style="height:250px;width:100%"/>
However once i do this the iframe does not get rendered in the new div. This works fine in firefox of course. If someone knows of a work around for this it would be much appreciated.
Why exactly are you doing this? I think you should use cloneNode anyway. Clone pdf1 and then append it to div1. Then instead of setting div2's display to 'none', remove it entirely (unless you need it for something else) using removeChild.
Also, next time you post code please use syntax highlighting (dropdown on top left of where you write your post).
Try using the console - click on that yellow triangle in the bottom left corner, and don't disable it if you're going to write scripts.
Originally Posted by bigcodfish
Perhaps not surprisingly, I.E. isn't expecting a keyword there.
This is a very simple version of code i am using in a page where I have two divs representing a normal and a maximized window, when the user clicks the maximize button on the normal window we detach the markup in that div and attach it in the maximized div. I will give clone node a try and see how that works, thanks for the tip.
Sorry about the confusion with the variable named if, thats not the name of the actual variable just something i entered when i was changing variable names in the post.