{"id":174,"date":"2006-05-08T21:27:57","date_gmt":"2006-05-08T19:27:57","guid":{"rendered":"http:\/\/www.maratz.com\/blog\/archives\/2006\/05\/08\/microsoft-activex-and-noscript\/"},"modified":"2010-04-12T17:02:29","modified_gmt":"2010-04-12T16:02:29","slug":"microsoft-activex-and-noscript","status":"publish","type":"post","link":"http:\/\/www.maratz.com\/blog\/archives\/2006\/05\/08\/microsoft-activex-and-noscript\/","title":{"rendered":"Microsoft, ActiveX and noscript"},"content":{"rendered":"<p>Microsoft did it again and now it affected much broader user-base. The funny thing is &#8211; I remember Flash fans used to say that Flash is a kind of interface that will run equally on each platform\/browser. Sweet&#8230;<\/p>\n<p>Since April 11th, all IE 6 patches (and IE 7 betas for that matter) deployed this ActiveX&#8230; <em>thing<\/em>. Read more about it at <a href=\"http:\/\/www.adobe.com\/devnet\/activecontent\/#captivate_before\">Adobe\/Macromedia<\/a>, it\u2019s too ugly to write about it here. What bothers me is that it affects my favorite Flash embedding method. Well, I guess, without this occassional crap &#8211; the life would be boring and I would be probably enjoying a cup of coffee somewhere in the down-town.<\/p>\n<p>Whichever method you choose to fix this, one thing is certain &#8211; you\u2019ll have to do it with JavaScript.<!--more--><\/p>\n<p>The sample workaround is deployed on the latest project from <a href=\"http:\/\/web.burza.hr\/\">Burza<\/a>, the <a href=\"http:\/\/www.hellgatelondon.com\/\">Hellgate: London<\/a> web site (if you\u2019re reading this in the monday eve <abbr title=\"Central European Timezone\">CET<\/abbr>, check it out tomorrow), so you might want to take a closer look at this live example.<\/p>\n<p>Basically, all we did was replacing a <code>noscript<\/code> content with some Flash embedding markup. The function for the external JavaScript file is:<\/p>\n<pre>\r\n\/* parent id, flash object id, movie source, width, height, scale, salign, menu *\/\r\nvar ifl = function(eI,oI,m,w,h,scale,salign,menu) {\r\n    var prnt = document.getElementById(eI);\r\n    if (!prnt) return;\r\n    var output = '&#60;object id=\"' + oI + '\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http:\/\/fpdownload.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=7,0,0,0\" width=\"' + w + '\" height=\"' + h + '\">'\r\n        + '&#60;param name=\"wmode\" value=\"transparent\" \/>'\r\n        + '&#60;param name=\"allowScriptAccess\" value=\"sameDomain\" \/>'\r\n        + '&#60;param name=\"movie\" value=\"' + m + '\" \/>'\r\n        + '&#60;param name=\"quality\" value=\"high\" \/>'\r\n        + (menu == 'false' ? '&#60;param name=\"menu\" value=\"false\" \/>' : '')\r\n        + '&#60;param name=\"Loop\" value=\"-1\" \/>'\r\n        + '&#60;param name=\"Src\" value=\"' + m + '\" \/>'               \r\n        + '&#60;param name=\"FlashVars\" value=\"\" \/>'\r\n        + '&#60;param name=\"Play\" value=\"0\" \/>'\r\n        + '&#60;param name=\"Loop\" value=\"-1\" \/>'\r\n        + '&#60;param name=\"SAlign\" value=\"' + (salign == 'lt' ? 'lt' : '') + '\" \/>'\r\n        + '&#60;param name=\"Base\" value=\"\" \/>'\r\n        + '&#60;param name=\"Scale\" value=\"' + (scale == 'noscale' ? 'noscale' : 'ShowAll') + '\" \/>'\r\n        + '&#60;param name=\"DeviceFont\" value=\"0\" \/>'\r\n        + '&#60;param name=\"EmbedMovie\" value=\"0\" \/>'\r\n        + '&#60;param name=\"BGColor\" value=\"\" \/>'\r\n        + '&#60;param name=\"SWRemote\" value=\"\" \/>'\r\n        + '&#60;param name=\"MovieData\" value=\"\" \/>'\r\n        + '&#60;param name=\"SeamlessTabbing\" value=\"1\" \/>'\r\n        + '&#60;embed src=\"' + m + '\" quality=\"high\" id=\"' + oI + '\" name=\"' + oI + '\" scale=\"' + scale + '\" salign=\"' + salign + '\" menu=\"' + menu + '\" allowScriptAccess=\"sameDomain\" type=\"application\/x-shockwave-flash\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" width=\"' + w + '\" height=\"' + h + '\" \/>'\r\n        + '&#60;\/object>';\r\n    prnt.innerHTML = output;\r\n};\r\n<\/pre>\n<p>Cheating, right? Yes, but it\u2019s also the fastest to render. Belive me, we tried <em>a lot<\/em> of methods. Plus, as I said many times before &#8211; <em>users first, standards second<\/em>.<\/p>\n<p>This is sample HTML chunk. You can call the <code>ifl<\/code> function right after the corresponding element, right before the closing <code>body<\/code> tag or perhaps with <code>onload<\/code> event.<\/p>\n<p>The most interesting fact is that if JavaScript is enabled &#8211; all the content inside <code>noscript<\/code> tags is not rendered, i.e. images are not loaded. Do you see the benefits? Inside the <code>noscript<\/code> tags you can create visually rich content wich will be loaded only if a user disabled JavaScript. Therefore the \u2018test\u2019 part of the JavaScript below. Try it to see what different browsers would \u2018recognize\u2019.<\/p>\n<pre>\r\n&#60;div id=\"header\">\r\n    &#60;noscript>\r\n        &#60;!-- noscript content goes here -->\r\n        &#60;p>For full experience, please &#60;strong>enable JavaScript&#60;\/strong> and &#60;a href=\"http:\/\/www.macromedia.com\/software\/flashplayer\/\">get Flash player&#60;\/a>&#60;\/p>\r\n    &#60;\/noscript>\r\n&#60;\/div>\r\n&#60;script type=\"text\/javascript\">\r\n    \/* &#60;![CDATA[ *\/\r\n        \/\/ test START\r\n        if (document.getElementById && document.getElementsByTagName) {\r\n            var summ = '';\r\n            var ins = document.getElementById('header').getElementsByTagName('noscript')[0].childNodes;\r\n            for (var i = 0; i < ins.length; i++) {\r\n                summ += ins[i].nodeValue + ' ;  ';\r\n            };\r\n        };\r\n        alert(ins.length + ' :  ' + summ);\r\n        \/\/ test END\r\n        ifl('header','flash_header','header.swf','300','200,'','','false');\r\n    \/* ]]> *\/\r\n&#60;\/script>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Elegant fallback with <code>noscript<\/code><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[26,38,36,32],"_links":{"self":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/174"}],"collection":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/comments?post=174"}],"version-history":[{"count":0,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/174\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/media?parent=174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/categories?post=174"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/tags?post=174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}