天天看點

BOM location-history-navigator對象

Location對象

var href=window.location.href; // 獲得目前url
var port = window.location.port; // 獲得目前端口
var hostname=window.location.hostname; // 獲得目前伺服器主機名
var host = window.location.host; //獲得目前主機名加端口

// 修改目前url位址
window.location.href = "https://www.baidu.com";
// 重新整理網頁
window.location.reload();
           

History 對象

// 傳回曆史記錄的數量
var len = window.history.length

// 後退按鈕
window.history.back();

// 前進按鈕
window.history.forword();

// 前進或後退指定步數
window.histroy.go(-1);
           

Screen對象

// 獲得目前螢幕的分辨率
var he = window.screen.height;
var wi = window.screen.width;
           

Navigator對象

// 傳回由客戶機發送伺服器的user-agent頭部的值
window.navigator.userAgent; // 請求頭部的使用者代理資訊
           

繼續閱讀