bom 의 총 결 1: window 대상
window 대상 은 브 라 우 저의 인 스 턴 스 입 니 다. 이중 역할 이 있 습 니 다. 자바 script 이 브 라 우 저 창 을 방문 하 는 인터페이스 이자 ECMAScript 의 Global 대상 입 니 다.
1. window 대상 의 전역 역할 영역
, , window
var age = 20;
console.log(window.age);
function sayAge() {
console.log(' :'+window.age);
}
window.sayAge();
1.1 window , delete
console.log(delete(age));// false
window.height = 180;
console.log(delete(window.height));// true
console.log(window.age);//
console.log(window.height);//
> :ie8 delete window ,
2. 창 관계 및 프레임 워 크
이 부분 은 나중에 보충 하면 자바 script 고급 프로 그래 밍 제3 판 P194 를 참고 할 수 있 습 니 다.
3. 창 위치
var leftPos = (typeof window.screenLeft == "number")?window.screenLeft:window.screenX;
var topPos = (typeof window.screenTop == "number")?window.screenTop:window.screenY;
alert(' :'+leftPos + ' :'+topPos);
,
> :window.moveTo window.moveBy .
4. 창 크기
// : chrome , IE8
console.log(' :'+ window.outerWidth + ' ' + window.outerHeight);
// :
var pageWidth = window.innerWidth,pageHeight = window.innerHeight;
if (typeof pageWidth != "number"){
if (document.compatMode == "CSS1Compat"){
pageWidth = document.documentElement.clientWidth;
pageHeight = document.documentElement.clientHeight;
} else {
pageWidth = document.body.clientWidth;
pageHeight = document.body.clientHeight;
}
}
5. 창 탐색 및 열기
// : . :1: url,
// 2. , :_blank,_self,_parent,_top
// 3. ,
// 4.
var otherWindow = window.open('http://piaoshu.org','otherWindow','height=400,width=400,left=100,top=100');
console.log(otherWindow.opener);
console.log(otherWindow.opener === window);// true
otherWindow.resizeTo(600,600);
console.log(otherWindow.closed);// false
otherWindow.close();
console.log(otherWindow.closed);// true
// ,
window.open('http://baidu.com');
// ,
//
var blocked = false;
try {
var wroxWin = window.open("http://www.wrox.com", "_blank");
if (wroxWin == null){
blocked = true;
}
} catch (ex){
blocked = true;
}
if (blocked){
alert(' , ');
}
6. 시간 초과 호출 과 간헐 호출
// : , js ,
// ,js , , .
var timeId = setTimeout(function () {
console.log(' ');
},1000);
clearTimeout(timeId);//
// : , ,
var count = 60, interval = null;
var logFun = function () {
console.log(' ');
console.log(count);
count -= 1;
if(count <= 50){
clearInterval(interval);
}
};
interval = setInterval(logFun,1000);
// ,, , ( ), :
var num = 0,max = 10;
var numFun = function () {
console.log(num);
num ++;
// ,
if(num <= max){
setTimeout(numFun,1000);
}
};
setTimeout(numFun,1000);
7. 시스템 대화 상자
// : ,
//1.alert:
alert(' alert ');
//2.confirm: , true ,
if(confirm(' ')){
alert(' ');
}else{
alert(' ');
}
//3.prompt
var result = prompt(' ',' ');
if(result != null){
console.log(' ');
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.