javascript使用小技巧

1.  通过javascript将一个数组分为三类,添加到一个数组中  


    var  input  = ins1 = $("#t1 .td");    //取出一个htmld页面中的所有table中的td  
    _add = [
        [],
        [],
        []
    ];
    console.log("111");
    for (i = 0; i < input.length; i++) {
        _add[i % 3].push($(input[i]));
    }


2.

获取div左上角坐标

var x=document.getElementById("start").offsetLeft ;
var y=document.getElementById("start").offsetTop ;


获取屏幕宽高

var w = screen.width

var h = screen.height


获取点击位置坐标

var e = event || window.event; 
var cx= e.clientX;

var cy= e.clientY;


document.body.clientWidth ==> BODY对象宽度
document.body.clientHeight ==> BODY对象高度



 s += " 网页可见区域宽:"+ document.body.clientWidth+" ";
            s += " 网页可见区域高:"+ document.body.clientHeight+" ";
            s += " 网页可见区域宽:"+ document.body.offsetWidth + " (包括边线和滚动条的宽)"+" ";
            s += " 网页可见区域高:"+ document.body.offsetHeight + " (包括边线的宽)"+" ";
            s += " 网页正文全文宽:"+ document.body.scrollWidth+" ";
            s += " 网页正文全文高:"+ document.body.scrollHeight+" ";
            s += " 网页被卷去的高(ff):"+ document.body.scrollTop+" ";
            s += " 网页被卷去的高(ie):"+ document.documentElement.scrollTop+" ";    
            s += " 网页被卷去的左:"+ document.body.scrollLeft+" ";
            s += " 网页正文部分上:"+ window.screenTop+" ";
            s += " 网页正文部分左:"+ window.screenLeft+" ";      
            s += " 屏幕分辨率的高:"+ window.screen.height+" ";
            s += " 屏幕分辨率的宽:"+ window.screen.width+" ";
            s += " 屏幕可用工作区高度:"+ window.screen.availHeight+" ";
            s += " 屏幕可用工作区宽度:"+ window.screen.availWidth+" ";
            s += " 你的屏幕设置是 "+ window.screen.colorDepth +" 位彩色"+" ";
            s += " 你的屏幕设置 "+ window.screen.deviceXDPI +" 像素/英寸"+" ";
            s += " window的页面可视部分实际高度(ff) "+window.innerHeight+" ";    
            s += " 网页可见区域宽:"+ document.body.clientWidth+" ";
            s += " 网页可见区域高:"+ document.body.clientHeight+" ";
            s += " 网页可见区域宽:"+ document.body.offsetWidth + " (包括边线和滚动条的宽)"+" ";
            s += " 网页可见区域高:"+ document.body.offsetHeight + " (包括边线的宽)"+" ";
            s += " 网页正文全文宽:"+ document.body.scrollWidth+" ";
            s += " 网页正文全文高:"+ document.body.scrollHeight+" ";
            s += " 网页被卷去的高(ff):"+ document.body.scrollTop+" ";
            s += " 网页被卷去的高(ie):"+ document.documentElement.scrollTop+" ";    
            s += " 网页被卷去的左:"+ document.body.scrollLeft+" ";
            s += " 网页正文部分上:"+ window.screenTop+" ";
            s += " 网页正文部分左:"+ window.screenLeft+" ";      
            s += " 屏幕分辨率的高:"+ window.screen.height+" ";
            s += " 屏幕分辨率的宽:"+ window.screen.width+" ";
            s += " 屏幕可用工作区高度:"+ window.screen.availHeight+" ";
            s += " 屏幕可用工作区宽度:"+ window.screen.availWidth+" ";
            s += " 你的屏幕设置是 "+ window.screen.colorDepth +" 位彩色"+" ";
            s += " 你的屏幕设置 "+ window.screen.deviceXDPI +" 像素/英寸"+" ";
            s += " window的页面可视部分实际高度(ff) "+window.innerHeight+" ";    


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值