转:Javascript 屏幕宽度,IE可视宽度,及浮动广告
mark
<script>
alert(screen.width+"*"+screen.height)
</script>
—————————————————————
screen.width
—————————————————————
<script>
function centerWindow(url,w,h){
l=(screen.width-w)/2
t=(screen.height-h)/2
window.open(url,'','left='+l+',top='+t+',width='+w+',height='+h)
}
</script>
<input type=button onclick="centerWindow('about:blank',200,200)">
—————————————————————
<body>
<SCRIPT LANGUAGE="JavaScript">
var s ="网页可见区域宽:"+ document.body.clientWidth;
s+="\r\n网页可见区域高:"+ document.body.clientHeight;
s += "\r\n网页正文全文宽:"+ document.body.scrollWidth;
s += "\r\n网页正文全文高:"+ document.body.scrollHeight;
s += "\r\n网页正文部分上:"+ window.screenTop;
s += "\r\n网页正文部分左:"+ window.screenLeft;
s += "\r\n屏幕分辨率的高:"+ window.screen.height;
s += "\r\n屏幕分辨率的宽:"+ window.screen.width;
s +="\r\n屏幕可用工作区高度:"+ window.screen.availHeight;
s +="\r\n屏幕可用工作区宽度:"+ window.screen.availWidth;
alert(s);
</SCRIPT>
—————————————————————
<SCRIPT LANGUAGE="JavaScript">
<!– Begin
function redirectPage() {
/*var url640x480 = "http://www.yoursite.com/640×480.html";**记得改相应的页面*/
var url800x600 = "index1.asp";
var url1024x768 = "index2.asp";
/*if ((screen.width == 640) && (screen.height == 480))
window.location.href= url640x480;*/
if (screen.width <= 800 )
window.location.href= url800x600;
else if ((screen.width >= 1024) )
window.location.href= url1024x768;
}
// End –>
</script>
======================================
<SCRIPT FOR=window EVENT=onload LANGUAGE="JavaScript">
initAd();//载入页面后,调用函数initAd()
</SCRIPT>
<script language="JavaScript">
<!–
function initAd() {
document.all.AdLayer.style.posTop = -200;
//设置onLoad事件激发以后,广告层相对于固定后的y方向位置
document.all.AdLayer.style.visibility = 'visible'//设置层为可见
MoveLayer('AdLayer');//调用函数MoveLayer()
}
function MoveLayer(layerName) {
var x = 600;//浮动广告层固定于浏览器的x方向位置
var y = 300;//浮动广告层固定于浏览器的y方向位置
var diff = (document.body.scrollTop + y – document.all.AdLayer.style.posTop)*.40;
var y = document.body.scrollTop + y – diff;
eval("document.all." + layerName + ".style.posTop = y");
eval("document.all." + layerName + ".style.posLeft = x");//移动广告层
setTimeout("MoveLayer('AdLayer');", 20);//设置20毫秒后再调用函数MoveLayer()
}
//–>
</script>
<!–下面为一个ID为AdLayer的层(如ID名不为AdLayer,
上面MoveLayer()内的AdLayer也要作相应修改),包括一张带链接的图片–>
<div id=AdLayer style='position:absolute; width:61px; height:59px; z-index:20; visibility:hidden;; left: 600px; top: 300px'>
<script>
var YahooCNADConfig=new Array();
YahooCNADConfig['adid']=909
YahooCNADConfig['wid']=28709
YahooCNADConfig['w']=110
YahooCNADConfig['h']=300
</script>
<script type='text/javascript' src='http://view.aliunion.cn.yahoo.com/showad.php'></script>
</div>
Tags: html, javascript
Leave a Reply
You must be logged in to post a comment.
近期评论