简体   繁体   English

如何在C#或JS中读取Flash文件的宽度和高度?

[英]How to read the width and the height of a flash file in C# or JS?

What will i do to read the width and the height of a flash file (*.swf) in C# or JS? 如何读取C#或JS中Flash文件(* .swf)的宽度和高度?

I tried a solution in CodeProject.com but return value of height is incorrect. 我在CodeProject.com中尝试了一种解决方案,但height的返回值不正确。

我想你可以用这个

您可以尝试“ SwfDotNet”

Did you try getComputedStyle ? 您尝试过getComputedStyle吗?
Here is a cross browser implementation coming from here 这是来自这里的跨浏览器实现

function getStyle(el, cssprop){
 if (el.currentStyle) //IE
  return el.currentStyle[cssprop]
 else if (document.defaultView && document.defaultView.getComputedStyle) //others
  return document.defaultView.getComputedStyle(el, "")[cssprop]
 else //try and get inline style
  return el.style[cssprop]
}

getStyle(elm, 'height')

It returns the value of any css property of an element. 它返回元素的任何css属性的值。

If that doesn't work you could try to embed your flash file in a DIV and measure it instead of the swf object. 如果这样不起作用,您可以尝试将Flash文件嵌入DIV中并测量它而不是swf对象。

EDIT: 编辑:

Here is an example that work on webkit, Opera. 这是在Webkit Opera上运行的示例。

<div id="container" style="float:left">
    <embed 
      type="application/x-shockwave-flash"
      src="http://s.ytimg.com/yt/swf/watch_as3-vfl178359.swf">
</div>
<script>
    var div = document.getElementById('container'),
        css = window.getComputedStyle(div, null);
    alert( css.height +' - '+ css.width );
</script>

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

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