我想知道是否可以使用javascript调整Flash大小。我无法单独更改flash对象中的任何代码,只有html,javascript和php才能使用。
到目前为止我发现了什么:
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;
}
}
内容嵌入是嵌入标记,内容对象是闪存中的对象标记。这适用于chrome(可能是firefox),但不是。
在Internet Explorer中我收到错误:Unable to set value of the property 'height': object is null or undefined
以下是我一直使用的示例页面:http://futuregamespc.com/behind/Popup/
有人可以帮忙吗?谢谢大家,你是这个网站真棒的原因。
答案 0 :(得分:1)
是的,这是可能的。
但是,每当您在网站上显示Flash时,请使用swfobject。
它是一个轻量级的JavaScript库 这允许你将swf集成到一个 跨浏览器友好的方式到你的 网站。
以下给出了对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);
如您所见,传递的height
和width
是参数
Read swfobject documentation了解更多详情。
更新:这是Adobe网站上的another good write up on using swfobject。