龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > Javascript编程 >

javascript学习笔记(三)BOM和DOM详解(4)

时间:2014-10-03 12:12来源:网络整理 作者:网络 点击:
分享到:
document对象 document对象:实际上是window对象的属性,document == window.document为true,是唯一一个既属于BOM又属于DOM的对象 document.lastModified //获取最后一次修改

document对象

document对象:实际上是window对象的属性,document == window.document为true,是唯一一个既属于BOM又属于DOM的对象 

document.lastModified //获取最后一次修改页面的日期的字符串表示 

document.referrer //用于跟踪用户从哪里链接过来的 

document.title //获取当前页面的标题,可读写 

document.URL //获取当前页面的URL,可读写 

document.anchors[0]或document.anchors["anchName"] //访问页面中所有的锚 

document.forms[0]或document.forms["formName"] //访问页面中所有的表单 

document.images[0]或document.images["imgName"] // 访问页面中所有的图像 

document.links [0]或document.links["linkName"] //访问页面中所有的链接 

document.applets [0]或document.applets["appletName"] //访问页面中所有的Applet 

document.embeds [0]或document.embeds["embedName"] //访问页面中所有的嵌入式对象 

document.write(); 或document.writeln(); //将字符串插入到调用它们的位置 

location对象

location对象:表示载入窗口的URL,也可用window.location引用它 

location.href //当前载入页面的完整URL,如http://www.somewhere.com/pictures/index.htm 

location.portocol //URL中使用的协议,即双斜杠之前的部分,如http 

location.host //服务器的名字,如www.wrox.com 

location.hostname //通常等于host,有时会省略前面的www 

location.port //URL声明的请求的端口,默认情况下,大多数URL没有端口信息,如8080 

location.pathname //URL中主机名后的部分,如/pictures/index.htm 

location.search //执行GET请求的URL中的问号后的部分,又称查询字符串,如?param=xxxx 

location.hash //如果URL包含#,返回该符号之后的内容,如#anchor1 

location.assign("http:www.baidu.com"); //同location.href,新地址都会被加到浏览器的历史栈中 

location.replace("http:www.baidu.com"); //同assign(),但新地址不会被加到浏览器的历史栈中,不能通过back和forward访问 

location.reload(true | false); //重新载入当前页面,为false时从浏览器缓存中重载,为true时从服务器端重载,默认为false 

navigator对象

 `navigator`对象:包含大量有关Web浏览器的信息,在检测浏览器及操作系统上非常有用,也可用window.navigator引用它 

`navigator.appCodeName` //浏览器代码名的字符串表示 

navigator.appName //官方浏览器名的字符串表示 

navigator.appVersion //浏览器版本信息的字符串表示 

navigator.cookieEnabled //如果启用cookie返回true,否则返回false 

navigator.javaEnabled //如果启用java返回true,否则返回false 

navigator.platform //浏览器所在计算机平台的字符串表示 

navigator.plugins //安装在浏览器中的插件数组 

navigator.taintEnabled //如果启用了数据污点返回true,否则返回false 

navigator.userAgent //用户代理头的字符串表示  

screen对象

 screen对象:用于获取某些关于用户屏幕的信息,也可用window.screen引用它 

 screen.width/height //屏幕的宽度与高度,以像素计 

 screen.availWidth/availHeight //窗口可以使用的屏幕的宽度和高度,以像素计 

 screen.colorDepth //用户表示颜色的位数,大多数系统采用32位 

 window.moveTo(0, 0); 

 window.resizeTo(screen.availWidth, screen.availHeight); //填充用户的屏幕  

window对象方法

BOM和DOM的结构关系示意图


window对象思维导图

精彩图集

赞助商链接