源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-文档对象模型
来源:互联网 发布:手机打电话录音软件 编辑:程序博客网 时间:2024/06/06 03:02
文档对象模型的最顶端对象是document对象,代表当前浏览器窗口或标签中载入的页面。
属性:title, lastModified, URL, domain
方法:write(), getElementById(), querySelectorAll(), createElement(), createTextNode()
示例:获取页面信息并显示到页脚
示例效果:
JS代码:
// Create a variable called msg to hold a message that will be shown on the page// Find the title of the document, and put this in the msg variablevar msg = '<p><b>page title: </b>' + document.title + '<br />';// Find the URL of the document and add it to the msg variablemsg += '<b>page address: </b>' + document.URL + '<br />';// Find the date the document was last modified and add it to the msg variablemsg += '<b>last modified: </b>' + document.lastModified + '</p>';// Create a variable called el to hold the element whose id attribute has a value of footervar el = document.getElementById('footer');// Write the message into that elementel.innerHTML = msg;
HTML代码:
<!DOCTYPE html><html> <head> <title>PD Hotel</title> <link rel="stylesheet" href="css/c03.css" /> </head> <body> <h1>PD Hotel</h1> <div id="footer"></div> <script src="js/document-object.js"></script> </body></html>
CSS代码:(参考源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-使用字面量语法创建对象,http://blog.csdn.net/hpdlzu80100/article/details/52677426 )
0 0
- 源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-文档对象模型
- 源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-浏览器对象模型
- 源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-String对象
- 源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-章节示例
- 源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-使用构造函数语法创建对象
- 源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-使用字面量语法创建对象
- 源码-JavaScript&jQuery交互式前端开发-第5章-文档对象模型-更新文本和标签
- 源码-JavaScript&jQuery交互式前端开发-第5章-文档对象模型-章节示例
- 源码-JavaScript&jQuery交互式前端开发-第7章-JQuery-基本示例
- 源码-JavaScript&jQuery交互式前端开发-第7章-JQuery-修改内容
- 源码-JavaScript&jQuery交互式前端开发-第2章-JavaScript基础指令-章节示例
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-鼠标事件-浮层的显示与关闭
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-Focus和blur事件
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-鼠标事件-确定光标位置
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-键盘事件-确定按键值
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-表单事件
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-变动事件
- 源码-JavaScript&jQuery交互式前端开发-第6章-事件-HTML5事件
- Kafka原理一
- 大并发架构师必读
- HTML+CSS基础 当p first-letter与first-line冲突时
- eclipse关联和生成javadoc文档
- 【JavaWeb-14】代理Proxy、动态代理、AOP编程思想、注解、元注解、类加载器
- 源码-JavaScript&jQuery交互式前端开发-第3章-函数、方法与对象-文档对象模型
- 微信小程序官方指南
- 进阶
- cudnn的安装,路径和版本问题
- JAVA常用的定时任务方法
- ORACLE SGA区基础知识与查看命令
- 大数取余
- C# 如何获取错误所在行数
- 均值滤波的快速解法