currently i am using bellow code
<html>
<head>
<script>
window.onload = function(){
var parser = new DOMParser();
var html = "<html><body><p>this is" +
"<script>document.write('dynamic')<\/script> text.</p></body></html>";
var doc = parser.parseFromString(html,'text/html');
document.body.appendChild(doc.body.children[0]);
}
</script>
</head>
<body>
<p>this is <script>document.write('dynamic')</script> text.</p>
</body>
</html>
that shows : this is dynamic text.
but currently i am loading page dynamicaly by ajax and parsing using new DOMParser. but it not prints "dynamic" only shows: this is text.
dwis designed to work. You can't use it to add content to a page after the page has been parsed, unless you don't want to re-write the whole document, including the head section. Use proper DOM manipulation methods instead.document.writeat all.