简体   繁体   中英

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?

I tried a solution in CodeProject.com but return value of height is incorrect.

我想你可以用这个

您可以尝试“ SwfDotNet”

Did you try 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.

If that doesn't work you could try to embed your flash file in a DIV and measure it instead of the swf object.

EDIT:

Here is an example that work on 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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