Convert Flash into HTML5, keep using Flash if browser does not support HTML5 -


my company using flash throughout website. want upgrade html5, while keep using flash if browser doesn't support html5. flash converted using google swiffy.

i have tried many solution, complicated. here current idea: create new audio object in try/catch statement, if browser supports it, print html5 code translated google swiffy, if jump catch statement, means browser doesn't support html5, use old code. here code:

try {     new audio();     // google swiffy code here  } catch (er) {     // use many lines of "document.write" old flash code     // many lines flash code } 

however, cannot import swiffy runtime code, because non-supporting browser complain runtime script, , stuck immediately. change code, import script manually this, don't know why doesn't work:

try {     new audio();      var js = document.createelement("script");      js.onload = function() {         document.body.appendchild(js);          // google swiffy code here     }      js.type = "text/javascript";     js.src = "https://www.gstatic.com/swiffy/v5.2/runtime.js";    } catch (er) {     alert(er);      <!--         displayflash('abc.swf', 420, 450);     //-->      document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http:\/\/fpdownload.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,0,0\" width=\"420\" height=\"450\" align=\"middle\"><param name=\"allowscriptaccess\" value=\"always\"><param name=\"movie\" value=\"..\/..\/images\/thap_deluxe.swf\"><param name=\"wmode\" value=\"transparent\"><param name=\"quality\" value=\"high\"><embed src=\"..\/..\/images\/thap_deluxe.swf\" wmode=\"transparent\" menu=\"false\" quality=\"high\" width=\"420\" height=\"450\" allowscriptaccess=\"always\" type=\"application\/x-shockwave-flash\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\"><\/object>"); } 

please suggest me better solution, or please teach me how fix problem current solution. thank you.

i think because js file never loads.
loads after append document.

try this:

try {     new audio();      var js = document.createelement("script");      js.type = "text/javascript";     js.src = "https://www.gstatic.com/swiffy/v5.2/runtime.js";      document.head.appendchild(js); // add head.  } catch (er) {     alert(er);      <!--         displayflash('abc.swf', 420, 450);     //-->      document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http:\/\/fpdownload.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,0,0\" width=\"420\" height=\"450\" align=\"middle\"><param name=\"allowscriptaccess\" value=\"always\"><param name=\"movie\" value=\"..\/..\/images\/thap_deluxe.swf\"><param name=\"wmode\" value=\"transparent\"><param name=\"quality\" value=\"high\"><embed src=\"..\/..\/images\/thap_deluxe.swf\" wmode=\"transparent\" menu=\"false\" quality=\"high\" width=\"420\" height=\"450\" allowscriptaccess=\"always\" type=\"application\/x-shockwave-flash\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\"><\/object>"); } 

// or if want in body, unless whole try / catch in window.onload

replace

document.head.appendchild(js); 

with:

window.onload = function(){     document.body.appendchild(js); } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -