Created
April 5, 2013 08:01
-
-
Save onexdrk/5317448 to your computer and use it in GitHub Desktop.
cross browser swf object create Example: var swf = createSwfObject('http://swf.url', {id: 'swfid', width: 250, height: 250}, {wmode: 'transparent'}); document.body.appendChild(swf);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createSwfObject(src, attributes, parameters) { | |
var i, html, div, obj, attr = attributes || {}, param = parameters || {}; | |
attr.type = 'application/x-shockwave-flash'; | |
if (window.ActiveXObject) { | |
attr.classid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'; | |
param.movie = src; | |
} | |
else { | |
attr.data = src; | |
} | |
html = '<object'; | |
for (i in attr) { | |
html += ' ' + i + '="' + attr[i] + '"'; | |
} | |
html += '>'; | |
for (i in param) { | |
html += '<param name="' + i + '" value="' + param[i] + '" />'; | |
} | |
html += '</object>'; | |
div = document.createElement('div'); | |
div.innerHTML = html; | |
obj = div.firstChild; | |
div.removeChild(obj); | |
return obj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment