window的对象有哪些(笔记)

 

window的主对象主要有以下几个:javascript

document 对象;html

frames 对象;java

history 对象;函数

location 对象;post

navigator 对象;url

screen 对象;spa

全局变量和函数都是window的属性。code

window的窗体函数:htm

 open() 函数:打开(弹出)一个新的窗体;对象

 close() 函数:关闭窗体;

 opener 属性:经过opener能够实现跨窗体之间的通信,可是要保证是在同一域名下,并且一个窗体要包含另外一个窗体的opener。

window.open(url, name, features, replace);

open函数参数说明:

url -- 要载入窗体的URL;

name -- 新建窗体的名称(也能够是HTML target属性的取值,目标);

features -- 表明窗体特性的字符串,字符串中每一个特性使用逗号分隔;

replace -- 一个布尔值,说明新载入的页面是否替换当前载入的页面,此参数一般不用指定。

对话框函数:

 alert() 函数;

 confirm() 函数:返回boolean值;

 prompt(str1,str2) 函数:可输入对话框(“此处str1不能编辑”、“str2能够编辑”)。

定时器经常使用函数:

时间等待与间隔函数:

setTimeout(a,b) 函数,指定时间以后执行的方法。a为要执行的方法,b为时间间隔,单位毫秒。

clearTimeout(i) 函数,清除指定的setTimeout函数执行,例:var i=setTimeout(a,b)。

setInterval(a,b) 函数,每隔时间b循环执行a;

clearInterval(i) 函数,清除定时器,例:var iu=setInterval。

window.location对象 

解析URL对象location

location对象的属性有:href,protocal,host,hostname,port,pathname,search,hash

复制代码
     document.write(location.href + "<br/>");        // http://localhost:4889/javascriptTest.html document.write(location.protocol + "<br/>"); // http: document.write(location.host + "<br/>"); // localhost:4889 document.write(location.hostname + "<br/>"); // localhost document.write(location.port + "<br/>"); // 4889 document.write(location.pathname + "<br/>"); // /javascriptTest.html document.write(location.search + "换行<br/>"); //http://localhost:4889/javascriptTest.html?id=1&name=张三 若是路径是这样,则输出 ?id=1&name=%E5%BC%A0%E4%B8%89 document.write(location.hash); //http: //localhost:4889/javascriptTest.html#kk=你好?id=1&name=张三 若是路径是这样,则输出 #kk=你好?id=1&name=张三
相关文章
相关标签/搜索