First of all thank you for quick response.
Let me tell you what I am trying to do.in this project. I go to settings page and create a new wall. then in my page (in this case tutorial page 3). than I call pdbinit function. which writes two div elements with document.write() and then fill inside divs with the data it gets from server. now here is the problem. if I use eval ,I wont be able to use document.write because My text will already be converted to elements and added to htmldom. so what I need is to use document.write in the text of innerhtml.
I simplified the question here is the code.
<html>
<head>
<script type="text/javascript">
function inject(targetDiv){
var content = '<b>This is the text before script</b> <script type="text/javascript">document.write("<br>This part is written via script")</script';
content +='>';//I am adding this here to broke </script!> tag
targetDiv.innerHTML = content;}
</script>
</head>
<body>
<div id="myDiv"></div><br>
<input type="button" value="inject HTML" onclick="inject(document.getElementById('myDiv'))"/>
<input type="button" value="Call Document.write after page load" onclick="document.write('Calling document.write after page load')"/>
</body>
</html>
Here I have a button when I click it , I inject an html (including some script) into the page. but script does not run. how can I run this. I also added a button to run document.write. if you press it it will run document.write. which will overwrite the content of the page. this has to be called by browser only when browser convert text to htmldom elements. (I am just guessing right now.)