Reputation: 1022
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.
Upvotes: 0
Views: 102
Reputation: 25164
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.
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>
Upvotes: 0