How to prevent an iframe from reloading when moving it in the DOM

Savageman picture Savageman · Sep 15, 2011 · Viewed 13k times · Source

I have an iframe loaded with some content. I would like to move it inside the DOM without causing a refresh (I like the content inside it, I want to keep it).

I'm doing some basic node.appendChild(iframe) to do the job.

Is that possible?

Thanks in advance for your help.

Answer

John Fisher picture John Fisher · Sep 15, 2011

If you're trying to move it visually, you can try modifying the CSS to use absolute positioning or some other adjustments.

However, if you're trying to actually pull it out of the DOM and insert it somewhere else, you won't be able to avoid a reload.