采用JS的方式使網頁中的flash自動適應分辨率、flash自適應分辨率代碼如下
JavaScript代碼
- <script type="text/javascript" language="JavaScript">
- e = true;
- var myWidth = 0, myHeight = 0;
- if( typeof( window.innerWidth ) == 'number' ) {
- myWidth = window.innerWidth;
- myHeight = window.innerHeight;
- } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
- myWidth = document.documentElement.clientWidth;
- myHeight = document.documentElement.clientHeight;
- } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
- myWidth = document.body.clientWidth;
- myHeight = document.body.clientHeight;
- }
- if (myWidth<800){
- myWidth=800;
- }
- if (myHeight<580){
- myHeight=580;
- }
- myWidth=myWidth-10;
- myHeight=myHeight-10;
- document.write('<OBJECT id="flashMovie" data="http://shss.zhiga.com/content/shss/uploadfiles/ydy.swf?myWidth='+ myWidth +'&myHeight='+ myHeight +'" type="application/x-shockwave-flash" WIDTH="'+ myWidth + '" HEIGHT="' + myHeight + '">');
- document.write('<PARAM NAME=movie VALUE="http://shss.zhiga.com/content/shss/uploadfiles/ydy.swf?myWidth='+ myWidth +'&myHeight='+ myHeight +'">');
- document.write('<PARAM NAME="FlashVars" VALUE="allowResize='+e+'" />');
- document.write('<PARAM NAME=quality VALUE=high>');
- document.write('<param name="BGCOLOR" value="#d3d3d3" />');
- document.write('<EMBED src="http://shss.zhiga.com/content/shss/uploadfiles/ydy.swf?myWidth='+ myWidth +'&myHeight='+ myHeight +'" quality=high bgcolor="#d3d3d3" WIDTH="'+ myWidth + '" HEIGHT="' + myHeight + '" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
- document.write('</OBJECT>');
- </script>