繁体   English   中英

使用Javascript调整Flash大小?

[英]Resize Flash with Javascript?

我想知道是否有可能使用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;
  }
}

内容嵌入是嵌入标签,内容对象是Flash中的对象标签。 这适用于Chrome(可能还适用于Firefox),但不适用于ie。 在Internet Explorer中,我收到错误消息: Unable to set value of the property 'height': object is null or undefined
这是我一直使用的示例页面: http : //futuregamespc.com/behind/Popup/谁能帮忙? 谢谢大家,您才是使该网站很棒的原因。

对的,这是可能的。

但是,每当您在网站上显示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);

如您所见,传递的heightwidth是参数。
有关更多详细信息,请阅读swfobject文档

更新:这是在Adobe网站本身上使用swfobject的另一篇很好的文章

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM