{"id":270,"date":"2012-12-31T10:19:29","date_gmt":"2012-12-31T18:19:29","guid":{"rendered":"http:\/\/shanelabs.com\/blog\/?p=270"},"modified":"2012-12-31T10:19:29","modified_gmt":"2012-12-31T18:19:29","slug":"calling-document-write-after-page-load-causes-blank-screen","status":"publish","type":"post","link":"https:\/\/shanelabs.com\/blog\/2012\/12\/31\/calling-document-write-after-page-load-causes-blank-screen\/","title":{"rendered":"Calling document.write after page load causes blank screen"},"content":{"rendered":"<p>I came across some interesting behavior when calling document.write multiple times. The first time I called it was fine, but if I called it again in a setTimeout, the page would go blank. Turns out that it&#8217;s because once the page loads and fires document ready event, it doesn&#8217;t know where the current cursor is. This causes the browser (happens in at least IE and FireFox) to start the page over from scratch, thus showing a blank screen.<\/p>\n<p>So, don&#8217;t make the javascript call document.write after the page has loaded!<\/p>\n<p>See this for <a href=\"http:\/\/www.htmlforums.com\/client-side-scripting\/t-error-on-multiple-documentwrites-38866.html\">more information<\/a><\/p>\n<p>Hope that helps you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I came across some interesting behavior when calling document.write multiple times. The first time I called it was fine, but if I called it again in a setTimeout, the page would go blank. Turns out that it&#8217;s because once the page loads and fires document ready event, it doesn&#8217;t know where the current cursor is. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-270","post","type-post","status-publish","format-standard","hentry","category-software","category-web"],"_links":{"self":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts\/270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/comments?post=270"}],"version-history":[{"count":2,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts\/270\/revisions"}],"predecessor-version":[{"id":272,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts\/270\/revisions\/272"}],"wp:attachment":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/media?parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/categories?post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/tags?post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}