{"id":192,"date":"2010-05-11T12:14:14","date_gmt":"2010-05-11T11:14:14","guid":{"rendered":"http:\/\/local.sandjam.co.uk\/?p=192"},"modified":"2018-08-03T14:00:55","modified_gmt":"2018-08-03T13:00:55","slug":"javascript-variable-names-in-internet-explorer","status":"publish","type":"post","link":"https:\/\/sandjam.co.uk\/sandjam\/2010\/05\/javascript-variable-names-in-internet-explorer\/","title":{"rendered":"Javascript variable names in Internet Explorer"},"content":{"rendered":"<p>The more I work with JavaScript the more I enjoy it. One of the things I like best is that it is a front-end language where you generally don&#8217;t have to worry about cross-browser compatibility. It usually just works&#8230;<\/p>\n<p>Usually&#8230;<\/p>\n<p>This one tripped me up and it took me a while to pin down what the problem was. Turns out the variable name &#8220;class&#8221; is reserved in IE but not in other browsers (Firefox\/Chrome).<\/p>\n<p>My code used a variable to insert a css class onto an element, something like:<\/p>\n<pre class=\"qoate-code\">\r\nvar class = \"blue\";\r\nelement.innerHTML = \"&lt;span class='\" + class + \"'&gt;comment&lt;\/span&gt;\";\r\n<\/pre>\n<p>I think this is because IE allows you to reference the css class of an object through this attribute, rather than using the &#8220;className&#8221; attribute.<\/p>\n<p>I guess this is another example of IE trying to make our lives &#8220;more compatible&#8221; but actually making it hard work for everyone.<\/p>\n<p>I also discovered IE8&#8217;s <a href=\"http:\/\/blogs.msdn.com\/jscript\/archive\/2008\/03\/13\/jscript-debugger-in-internet-explorer-8.aspx\">new debugger<\/a> during this time though which actually tells you where your JS errors lie, rather than just saying &#8220;Line 1 character 2342&#8221;.<\/p>\n<p>Finally something to make a developer&#8217;s life easier in IE!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The more I work with JavaScript the more I enjoy it. One of the things I like best is that it is a front-end language where you generally don&#8217;t have to worry about cross-browser compatibility. It usually just works&#8230; Usually&#8230; This one tripped me up and it took me a while to pin down what [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4],"tags":[27,14],"class_list":["post-192","post","type-post","status-publish","format-standard","hentry","category-code","tag-internet-explorer","tag-javascript"],"acf":[],"_links":{"self":[{"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/posts\/192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/comments?post=192"}],"version-history":[{"count":6,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/posts\/192\/revisions"}],"predecessor-version":[{"id":1108,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/posts\/192\/revisions\/1108"}],"wp:attachment":[{"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/media?parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/categories?post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sandjam.co.uk\/sandjam\/wp-json\/wp\/v2\/tags?post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}