JavaScript BOM 相关知识

来源:互联网 发布:vim node inspector 编辑:程序博客网 时间:2024/06/05 20:18

location.reload();

location.href = '';

location.hash

location.hostname

location.pathname

location.search

location.protocol


screen.availHeight;    //returns screen height in pixels

screen.availWidth;    //returns screen width in pixels


window.innerHeight;    //returns browser view port height in pixels

window.innerWidth;    //returns browser view prot width in pixels

window.pageXOffset;    //returns number of pixels the page has scrolled to the right

window.pageYOffset;    //returns number of pixels the page has scrolled down


var win = window.open()

win.close();

window.open('http://www.baidu.com');

window.status = '';



document.open()

document.write()

document.writeln()

document.close()



history.back();

history.forward();

history.go(-1);



confirm(msg)

alert(msg)

prompt(msg)



var timeId = setTimeout(function(){}, 1000);

clearTimeout(timeId);

var timeId = setInterval(function(){}, 1000);

clearInterval(timeId);



cookie


function setCookie(name, value, days){

    var date = new Date();

    date.setTime(date.getTime()+(days*24*60*60*1000));

    var expires = date.toGMTString();

    document.cookie = name + '=' + value + expires + '; path=/';

}


function getCookie(name){

    var cArr = document.cookie.split(';');

    for(var i = 0, l = cArr.length; i < l; i++){

        var cookie = cArr[i].split('=', 2);

        cookie[0] = cookie[0].replace(/^\s+/, '');

        if(cookie[0] == name){

            return cookie;

        }

    }

}

0 0