Javascript 扩展HTML5嵌入swf以适应div维度
我有以下设置:Javascript 扩展HTML5嵌入swf以适应div维度,javascript,html,embed,flash,Javascript,Html,Embed,Flash,我有以下设置: <div class="creative"> <embed src="..." type="application/x-shockwave-flash" scale="showall" wmode="opaque" allowScriptAccess="always" flashvars="..."/>'; </div> //==== CSS ==== .creative { width = 325px; height= 350px }
<div class="creative">
<embed src="..." type="application/x-shockwave-flash" scale="showall" wmode="opaque" allowScriptAccess="always" flashvars="..."/>';
</div>
//==== CSS ====
.creative {
width = 325px;
height= 350px }
';
//==CSS====
.创意{
宽度=325px;
高度=350px}
我想嵌入swf文件,以适应这个维度,但规模不做我想要的。我还尝试了width=100%和height=100%,但使swf文件获得所有空间,并且当有字母出现在场景之外时,它们是可见的
一个想法是使用javascript调整它的大小,但您是否对html5嵌入的任何属性有任何建议,以便自动执行此操作
提前谢谢 最后使用js实现了这一点,我使用以下函数根据我希望嵌入元素成为的容器来计算新的维度
/* Calculates the new scaled dimensions
* srcWidth: Swf real width
* srcHeight: Swf real height
* maxWidth: Container's width
* maxHeight: Container's height
*/
function calculateAspectRatioFit (srcWidth, srcHeight, maxWidth, maxHeight) {
var ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight);
return { width: Math.round(srcWidth*ratio), height: Math.round(srcHeight*ratio) };
};