根据显示器分辨率调整页面显示宽度的Javascript脚本
代码示例:
1.根据分辨率,使用不同的代码.
<
script type
=
"
text/javascript
"
>
// <![CDATA[
if (screen.width > 1100 )
Insert_Flash( ' flashcontent ' , " images/banner1280.swf " , " 100% " , 105 );
// Insert_Flash是我自己写的插入flash的脚本.我为不同分辨率做了不同的flash
// 如果你要插入图片,可以用 document.write('<img src="1280.png">');
else
Insert_Flash( ' flashcontent ' , " images/banner1024.swf " , " 100% " , 105 );
// ]]>
< / script>
// <![CDATA[
if (screen.width > 1100 )
Insert_Flash( ' flashcontent ' , " images/banner1280.swf " , " 100% " , 105 );
// Insert_Flash是我自己写的插入flash的脚本.我为不同分辨率做了不同的flash
// 如果你要插入图片,可以用 document.write('<img src="1280.png">');
else
Insert_Flash( ' flashcontent ' , " images/banner1024.swf " , " 100% " , 105 );
// ]]>
< / script>
2.根据分辨率,修改css
<
script type
=
"
text/javascript
"
>
if (screen.width > 1100 )
document.getElementById( " text_flash " ).style.left = " 600px " ;
< / script>
if (screen.width > 1100 )
document.getElementById( " text_flash " ).style.left = " 600px " ;
< / script>