Skip to content

Instantly share code, notes, and snippets.

@onexdrk
Created April 5, 2013 08:01
Show Gist options
  • Save onexdrk/5317448 to your computer and use it in GitHub Desktop.
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);
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