I have a website with a large .swf file. However when people with smaller screens view the website, I would like the .swf (which takes up the entire screen) to resize to fit on exactly. Just like how开发者_JAVA技巧 on most flash sites when viewed they fit the screen perfectly, however also then when viewed on computers with smaller screens they resize and still fit perfectly again.
If you link directly to the swf file (not embedding it in any page) it'll be full-screen.
You could generate the <object>
tag which embeds the SWF file via JavaScript and print the width and height programmatically based on the size of the containing window. For example:
<script type="text/javascript">
var w=window.innerWidth, h=window.innerHeight;
document.write('<object width="' + w + '" height="' + h + '">');
document.write(' <param name="movie" value="x.swf">');
document.write(' <embed src="x.swf" width="100%" height="100%"></embed>');
document.write('</object>');
</script>
The method for retrieving the window width/height will probably vary per browser but I'm sure you can find a reliable, cross-browser way to do it somewhere online.
If you need to dynamically resize whenever the window is resized then you can attach a handler to the window.onresize
event which retrieves the necessary object and embed DOM elements and change their width
and height
properties. Probably. I haven't tested any of this.
精彩评论