how convert iframe to div in javascript? [closed]
Edit: all details that I know are in post. If you want even more details please Try help to discover in what language of programming I have isolation issues. The problem in my page is that i need to run an API inside an iframe(lets call iframelyrics but in my code i called "myiframeid") that conflicts with my maincode, and for visualisation purposes, i need to convert the iframelyrics to div. Here is my code:
<script type="text/javascript">
content = null
function onTryItClick() {
function loadXMLDoc(theURL) {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari, SeaMonkey
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
content = xmlhttp.responseText
}
}
xmlhttp.open("GET", theURL, false);
xmlhttp.send();
}
var xmlhttp = false;
loadXMLDoc('X-Raym_Lyrics.html');
var iframe = document.getElementById("myiframeid");
var frameDoc = iframe.document;
if (iframe.contentWindow)
frameDoc = iframe.contentWindow.document;
frameDoc.open();
frameDoc.writeln(content);
frameDoc.close();
}
</script>
How convert that iframe to an div (i need a thing that works offline)?
I tried a variation of this:
var iframe= document.getElementById("myiframeid");
var div = document.createElement("div");
document.body.appendChild(div);
div.innerHTML = iframe.innerHTML;
iframe.parentNode.removeChild(iframe);
Comments
Post a Comment