新手求助:如何获得屏幕宽度

在做页面时,用户要求,不同的分辨率,弹出窗口的位置不同
我想是不是先获得屏幕宽度,然后付值给变量,再在onclick中设置参数
哪位大哥有这方面的例子,还请多帮忙
---------------------------------------------------------------

1<script>   
2alert(screen.width+"*"+screen.height)   
3</script>

---------------------------------------------------------------

screen.width
---------------------------------------------------------------

1<script>   
2function centerWindow(url,w,h){   
3l=(screen.width-w)/2   
4t=(screen.height-h)/2   
5window.open(url,'','left='+l+',top='+t+',width='+w+',height='+h)   
6}   
7</script>
1<input onclick="centerWindow('about:blank',200,200)" type="button"/>

---------------------------------------------------------------

 1<body>
 2<script language="JavaScript">   
 3var s ="网页可见区域宽:"+ document.body.clientWidth;   
 4s+="\r\n网页可见区域高:"+ document.body.clientHeight;   
 5s += "\r\n网页正文全文宽:"+ document.body.scrollWidth;   
 6s += "\r\n网页正文全文高:"+ document.body.scrollHeight;   
 7s += "\r\n网页正文部分上:"+ window.screenTop;   
 8s += "\r\n网页正文部分左:"+ window.screenLeft;   
 9s += "\r\n屏幕分辨率的高:"+ window.screen.height;   
10s += "\r\n屏幕分辨率的宽:"+ window.screen.width;   
11s +="\r\n屏幕可用工作区高度:"+ window.screen.availHeight;   
12s +="\r\n屏幕可用工作区宽度:"+ window.screen.availWidth;   
13alert(s);   
14</script>   
15\---------------------------------------------------------------   
16  
17<script language="JavaScript">   
18<!-- Begin   
19function redirectPage() {   
20/*var url640x480 = "http://www.yoursite.com/640x480.html";**记得改相应的页面*/   
21var url800x600 = "index1.asp";   
22var url1024x768 = "index2.asp";   
23/*if ((screen.width == 640) && (screen.height == 480))   
24window.location.href= url640x480;*/   
25if (screen.width <= 800 )   
26window.location.href= url800x600;   
27else if ((screen.width >= 1024) )   
28window.location.href= url1024x768;   
29}   
30// End -->   
31</script>   
32  
33这段代码是根据不同的屏幕显示不同的页面   
34============================================   
35下面是传递这个参数的   
36<script language="JavaScript">   
37document.write("<a href='WebStat/index.asp'>");   
38document.write("<img src='WebStat/count.asp?Referer=```
39=refer
40```&Width="+escape(screen.width)+"&Height="+escape(screen.height)+"' border=0 width=1 height=1>");   
41document.write("</a>");   
42</script></body>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus