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获取屏幕,浏览器窗口大小,网页高度宽度

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页面跳转常用的几种方式

posted @ 2017-10-12 00:04  zhen-Android  阅读(497)  评论(0编辑  收藏  举报