Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- document.write in jsonp callback


yogesh - 6:11 am on Dec 29, 2011 (gmt 0)


Hello penders, Thanks for replying.

If I understand correctly, document should get overwritten with new content if document.write was called after onload. This however, does not happen and I can't figure out why this is the case.

I have following div where I expected it to get written.

<div>
<script type='text/javascript' src="myscript.js"></script>
<!-- Myscipt has the jsonp code and callback function listed above -->
</div>


I am writing the iframe in following manner.

var iframe = document.createElement("iframe");
/*I do not want to append to body though. I want to append to div */
document.body.appendChild(iframe);
var doc = iframe.document;
if(iframe.contentDocument){
doc = iframe.contentDocument; // For NS6
}
else if(iframe.contentWindow){
doc = iframe.contentWindow.document; // For IE5.5 and IE6
}
doc.open();
doc.write(data);
doc.close();


Thread source:: http://www.webmasterworld.com/javascript/4401935.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com