Resize Flash with Javascript?
I'm wondering if its possible to resize flash with javascript. I can't change any code in the flash object alone all I have is html, javascript and php to work with.
Heres what I've found so far:
var changeMe = document.getElementById("content_embed");
changeMe.height = yy;
changeMe.width = xx;
if (navigator.userAgent.toLowerCase().indexOf("safari")!=-1开发者_如何学运维) {
var changemeObject = document.getElementById("content_object");
changeMeObject.height = yy;
changeMeObject.width = xx;
}
}
Content Embed is the embed tag and content object is the object tag in the flash. This works in chrome (and probably firefox) but not ie.
In internet explorer I get the error: Unable to set value of the property 'height': object is null or undefined
Yes it is possible.
But, please use swfobject whenever you display flash in your website.
Its a lightweight JavaScript library that allows you to integrate swf in a cross browser friendly way to your website.
The below given is a sample of the call to swfobject
var flashvars = {};
var params = {};
var attributes = {};
var width="300";
var height="120";
swfobject.embedSWF("myContent.swf", "myContent", width, height, "9.0.0","expressInstall.swf", flashvars, params, attributes);
As you can see, height
and width
are passed are parameters.
Read swfobject documentation for more details.
Update: Here is another good write up on using swfobject on the Adobe site itself.
精彩评论