html 窗口管理

获取body/window宽高度API

var s = "";
s = document.body.innerHeight;	// undefine
s = document.body.innerWidth;
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 + " 像素/英寸";
Ref:
  js获取浏览器body或窗宽度高度合集
  JS获取屏幕,浏览器窗口大小,网页高度宽度

页面跳转与传值

/**
 * 页面跳转与传值
 * 	http://www.cnblogs.com/cyy-13/p/5775344.html
 * 	http://www.jb51.net/article/25403.htm
 */
function testPageJump(){
    debugger;
    // cookie传值
    document.cookie = "AAA=aaa&BBB=bbb";
    // localStorage传值
    localStorage.CCC = "ccc";
    localStorage.setItem("AAA","aaa");
    // sessionStorage传值
    sessionStorage.setItem("BBB","bbb");

    // 参数传值
    // 在当前页面打开
    window.location.href = "PageB.html?AAA=aaa&BBB=bbb";
    // 在当前页面打开
    self.location = "PageB.html";
    // 在当前页面打开
    top.location = "PageB.html";
    // 打开新页面
    window.open("PageB.html?AAA=aaa&BBB=bbb");
    // ie?
    window.navigate("PageB.html");
    window.navigate("http://www.baidu.com");
    // 返回
    window.history.back(-1);
}
/**
 * B页面
 */
console.log(window.location.href);
console.log(document.cookie);
console.log(localStorage.CCC);
console.log(localStorage.getItem("AAA"));
console.log(sessionStorage.getItem("BBB"));
/**
 * url参数解析
 * @param {Object} params
 */
function parseUrl(params) {
    try {
        var paramPair = params.split("?")[1].split("&");
        var parmObj = {};
        for(var vpar in paramPair) {
            var spPair = paramPair[vpar].split("=");
            parmObj[spPair[0]] = spPair[1];
        }
        console.log(parmObj);
    } catch(ex) {
        console.log(ex.message);
    }
}



参考:

     Window open() 方法

     JS页面跳转大全

     js页面跳转常用的几种方式


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值