Warning: curl_exec() has been disabled for security reasons in /pub/host/sunboyu/sunboyu/www/wp-includes/http.php on line 1022
2008 八月 04 一个程序猿 孙小一,孙小二,PHP,MYSQL,LINUX,APACHE,原创技术,扯淡

几个JS函数,自家用,共享之

作者 : admin 于 2008年08月04日, 18:45:12
2008
08-4

检测浏览器类型,主要根据 userAgent关键字来确定

  1. function __navigator()
  2. {
  3.     this.value = false;   //返回值  ie 0 firefox 1 other 2
  4. this.useragent =  navigator['userAgent'];
  5. if(this.useragent.indexOf('MSIE')>0)
  6. {
  7.     this.value = 0;
  8. }
  9. else if(this.useragent.indexOf('Firefox')>0)
  10. {
  11.     this.value = 1;
  12. }
  13. else
  14. {
  15.     this.value = 2;
  16. }
  17. }

获得浏览器相关信息

  1. function __window()
  2. {
  3.     this.innerwidth = 0;   //document width
  4. this.innerheight = 0; //document height
  5.  
  6. this.outerwidth = 0;   //browser width
  7. this.outerwidth = 0;   //browser height
  8.  
  9. this.screenx = 0;     //browser position x
  10. this.screeny = 0;   //browser position y
  11.  
  12.     /*@cc_on
  13.   @if(@_jscript)
  14.  
  15.   this.innerwidth = document.body.clientWidth;
  16.   this.innerheight = document.body.clientHeight;
  17.  
  18.   this.outerwidth = document.documentElement.clientWidth;
  19.   this.outerheight = document.documentElement.clientHeight;
  20.  
  21.   this.screenx = window.screenLeft;
  22.   this.screeny = window.screenTop;
  23.  
  24.   @else*/
  25.  
  26.   this.innerwidth = window.innerWidth;
  27.   this.innerheight = window.innerHeight;
  28.  
  29.   this.outerwidth = window.outerWidth;
  30.   this.outerheight = window.outerHeight;
  31.  
  32.   this.screenx = window.screenX;
  33.   this.screeny = window.screenY;
  34. /*@end
  35.   @*/
  36. }