We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

arpit on 06/29/09


Tagged

flash


Versions (?)


Javascript window sizing for swf


Published in: JavaScript 


URL: http://www.thetechlabs.com/tutorials/flash/swfobject-and-best-practice-implementation/

  1. function setFlashSize(flashWidth,flashHeight){
  2. var size = [0,0];
  3. if( typeof( window.innerWidth ) == 'number' ) {
  4. size = [window.innerWidth, window.innerHeight];
  5. } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
  6. size = [document.documentElement.clientWidth, document.documentElement.clientHeight];
  7. } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
  8. size = [document.body.clientWidth, document.body.clientHeight];
  9. }
  10. window.onresize = function() {
  11. document.getElementById("flashContainer").style.minWidth = flashWidth+"px";
  12. document.getElementById("flashContainer").style.minHeight = flashHeight+"px";
  13. document.getElementById("flashContainer").style.width = size[0] < flashWidth ? flashWidth+"px" : "100%";
  14. document.getElementById("flashContainer").style.height = size[1] < flashHeight ? flashHeight+"px" : "100%";
  15. };
  16. window.onload = function(){
  17. window.onresize();
  18. }
  19. }
  20. SWFObject.embedSWF("example.swf", "flashMovie", "100%", "100%", "6.0.0","expressInstall.swf");
  21. setFlashSize(600,400);

Report this snippet 

You need to login to post a comment.