Last active
November 13, 2019 14:13
-
-
Save caot/fac3aa0480680d59780cbc4717810023 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<script src="jquery.min.js"></script> | |
</head> | |
<body> | |
<iframe id="myFrame" style="height:180px;width:100%"></iframe> | |
<script> | |
var iframe = document.getElementsByTagName('iframe')[0]; | |
iframe.src = 'about:blank'; | |
function myFunction() { | |
// var iframe = document.getElementsByTagName('iframe')[0]; | |
// iframe.src = 'about:blank'; | |
iframe.contentWindow.document.open(); | |
iframe.contentWindow.document.write(html); | |
iframe.contentWindow.document.close(); | |
var elmnt = iframe.contentWindow.document.getElementsByTagName("H1")[0]; | |
console.log([elmnt, elmnt.innerText]); | |
}; | |
$( document ).ready(function() { | |
myFunction(); | |
}); | |
const html = ` | |
<!DOCTYPE html> | |
<html lang="en-us"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Page Title</title> | |
</head> | |
<body> | |
<div class="w3-col l6 w3-center"> | |
XXXXX | |
<h1>HTML</h1> | |
YYYYY | |
</div> | |
</body> | |
</html> | |
` | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment