{"id":131,"date":"2008-05-18T14:37:00","date_gmt":"2008-05-18T14:37:00","guid":{"rendered":"\/lisa\/post\/2008\/05\/18\/YAPS-IE-6-body-onload-n-U.aspx"},"modified":"2008-05-18T14:37:00","modified_gmt":"2008-05-18T14:37:00","slug":"yaps-ie-6-body-onload-n-u","status":"publish","type":"post","link":"https:\/\/spacefold.com\/lisa\/2008\/05\/18\/yaps-ie-6-body-onload-n-u\/","title":{"rendered":"YAPS: IE 6, body onload, &#8216;n U"},"content":{"rendered":"<p>\nI&#39;ve decided&nbsp;I should have a blog category called &quot;YAPS&quot; (Yet Another PostScript), for all the times when I post and then think of something more I want to say to clarify on the subject later. This one clarifies <a href=\"\/lisa\/2008\/03\/09\/Anchors-Aweigh-Away\/\">http:\/\/www.spacefold.com\/lisa\/Anchors-Aweigh-Away<\/a>.\n<\/p>\n<p>\nIt turns out that under some very specific circumstances IE&nbsp;6 isn&#39;t calling the body onload function, which is the logical place to put the navCheck function I discussed in that blog post.&nbsp; It&#39;s not due to anything specific in my javascript; you can see the same behavior with <em>anything<\/em> in the body onload, for any page on which this occurs.\n<\/p>\n<p>\nIt actually works fine on Spacefold Articles, even in IE 6. So I suspect&nbsp;seeing the issue requires&nbsp;having a code-behind page, in your master page (because the SpacefoldArticles.Master file doesn&#39;t).&nbsp; It might also require having a&nbsp;Page_Load function in that code-behind page.&nbsp; Maybe ASP.NET handling either pre-empts the onload, or doesn&#39;t piggyback on it correctly from IE 6&#39;s POV, or just does something else in the wrong sequence, in this situation.&nbsp;\n<\/p>\n<p>\nOh wait &#8212; it may depend on your current DOCTYPE, too, because IE 6 is finicky about what it does and how it&nbsp;complies with standards (or doesn&#39;t)&nbsp;depending on DOCTYPE.&nbsp; My DOCTYPE declaration for the &quot;problem page&quot; happens to be:\n<\/p>\n<p class=\"code\">\n&lt;!DOCTYPE html PUBLIC &quot;-\/\/W3C\/\/DTD HTML 1.0 Transitional\/\/EN&quot; <br \/>\n&quot;<a href=\"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd<\/a>&quot;&gt;\n<\/p>\n<p>\nWhatever.&nbsp; I&#39;ve seen a lot of people point to mysterious failures of body onload in IE 6.&nbsp; Here is <a href=\"http:\/\/www.webmasterworld.com\/javascript\/3382798.htm\" target=\"_blank\" title=\"sample body onload and IE 6 issue post\" rel=\"noopener\">an example<\/a>.&nbsp; There&#39;s a broad range of descriptions and observations of the failures.&nbsp;&nbsp;Just type &quot;body onload ie 6&quot; in the search engine of your choice, and you&#39;ll doubtless see.\n<\/p>\n<p>\nSo here&#39;s my resolution: take the javascript <em>out<\/em> of the onload call, just don&#39;t use&nbsp;that event. Rather than getting fancy with adding events or figuring out whatever messiness the ASP.NET sequence is causing &quot;behind the scenes&quot;&#8230;&nbsp;&nbsp;call&nbsp;the same script&nbsp;<em>after all relevant elements in the page have been rendered, directly in the body of the page.&nbsp; <\/em>\n<\/p>\n<p>\nIn my case, that means that the master page finishes up like this:\n<\/p>\n<p class=\"code\">\n<span style=\"color: green\">&lt;!&#8211; more here &#8211;&gt;<br \/>\n<\/span>&lt;asp:ContentPlaceHolder ID=&quot;MainContentArea&quot; runat=&quot;server&quot;&gt;<br \/>\n&nbsp;&lt;\/asp:ContentPlaceHolder&gt;<br \/>\n&nbsp;&lt;\/div&gt;<br \/>\n<span style=\"color: green\">&nbsp;&nbsp;&lt;!&#8211; Bottom Information Area &#8211;&gt;<br \/>\n<\/span>&nbsp;&nbsp;&lt;div id=&quot;BottomArea&quot;&gt;<br \/>\n&nbsp;&nbsp; yadayadayada<br \/>\n&nbsp;&nbsp; &nbsp;&nbsp;&lt;\/div&gt;&nbsp;&nbsp;<br \/>\n&lt;\/form&gt; <br \/>\n<span style=\"color: green\">&lt;!&#8211; run the script after all the elements are defined &#8211;&gt; <br \/>\n<\/span><span style=\"color: red\">&lt;script&gt; <br \/>\n&nbsp;&nbsp; navCheck(); <br \/>\n&lt;\/script&gt;&nbsp; <br \/>\n<\/span>&lt;\/body&gt; <br \/>\n&lt;\/html&gt;\n<\/p>\n<p>\nIf you&#39;re not trying to access items on the page, you can probably put it somewhere more intuitive in the body, but (as you may remember from the <a href=\"\/lisa\/2008\/03\/09\/Anchors-Aweigh-Away\/\" title=\"Anchors Away post with navCheck code\">original post<\/a>), the navCheck() function is going to try to find an element on the page, using document.getElementById,&nbsp;and jump to that element if it&#39;s found.&nbsp; So&nbsp;all the page elements&nbsp;have to be prepared and available, before this script actually runs.\n<\/p>\n<h5>Is that better than a plan?<\/h5>\n<p>\nSeems to work&#8230; in FireFox, Opera, IE, and Safari.\n<\/p>\n<p>\nWeird, huh?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#39;ve decided&nbsp;I should have a blog category called &quot;YAPS&quot; (Yet Another PostScript), for all the times when I post and then think of something more I want to say to clarify on the subject later. This one clarifies http:\/\/www.spacefold.com\/lisa\/Anchors-Aweigh-Away. It turns out that under some very specific circumstances IE&nbsp;6 isn&#39;t calling the body onload function,<a class=\"more-link\" href=\"https:\/\/spacefold.com\/lisa\/2008\/05\/18\/yaps-ie-6-body-onload-n-u\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,12],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-asp-net","category-yaps"],"_links":{"self":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":0,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"wp:attachment":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}