I can 前端-05 DOM模型与Window对象
来源:互联网 发布:网络性能参数指标 编辑:程序博客网 时间:2024/06/03 03:50
网页需要交互,但网页如果很复杂,交互的话怎么去操控呢?
事实上,网页上的对象按照一定的结构排列
DOM(Document Object Model)
操控网页的标准
- 规定了HTML文档中各个对象属性、方法和事件的标准
- 描述了整个HTML文档,浏览器通过它管理和显示各个元素
- 我们通过编程访问来修改
DOM是我们操控整个网页的标准
对象关系
对象布局
Window对象和常用方法
window对象属性
document
!!!中国人口何其多,如何找到某个人
方法1:身份证号码 document.getElementById(“元素id”)
方法2:省份/城市/区县/街道/小区/门牌号/姓名 form名称.元素名
<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title>测试操控对象的方法</title> <script type="text/javascript"> function GetUserInfo(){ //window对象是顶层对象对象,可以忽略不写,document/window.document var userName = document.getElementById("userName").value; var pwd = userForm.pwd.value; alert(userName); alert(pwd); } </script> </head> <body> <form name="userForm" method=""> 账户名:<input type="text"id="userName"/> 密码:<input type="text" name="pwd"/> <input type="button" value ="提交" onclick="GetUserInfo()" /> </form> </body></html>
每个html标签都有id和name属性
getElementBy() 根据元素ID获取唯一对象
getElementByName() 根据元素名称获取一组同名对象
location
填写URL,改变页面跳转或加载
href-设置/获取要操作的URL
reload()-重新加载当前页面
replace(“url”)-加载新页面替换当前页面
history
history.back() 后退
history.forward() 前进
剩余的
状态栏信息
window.status = “系统当前状态:正在等待用户提交数据!”
屏幕宽度
window.screen.width
window对象常用方法
对话框
- alert
- confirm
打开新窗口
<!DOCTYPE html><html><head> <title>window对象方法</title> <script type="text/javascript"> function openNewWindow() { window.open("userLogin.html", "用户登录", "toolbar=0, location=0, status=0,menubar=0,width=300px,height=200px,scrollbars=1"); } </script></head><body> <input type="button" value="打开新窗口" onclick="openNewWindow()" /> <input type="button" value="关闭当前窗口" onclick="window.close()" /></body></html>
打开模态窗口
<!DOCTYPE html><html><head> <title>打开模式对话框</title> <script type="text/javascript"> function openNewWindow() { showModalDialog("userLogin.html", "用户登录", "status=0;dialogWidth=300px;dialogHeight=200px;scroll=1"); } </script></head><body> <input type="button" value="打开模式窗口" onclick="openNewWindow()" /></body></html>
onLoad事件
- 在窗口完成文档内容加载时触发
阅读全文
0 0
- I can 前端-05 DOM模型与Window对象
- Window对象与DOM
- I can 前端-03 盒子模型
- [Web前端]梳理-DOM.13. window常用子对象
- I can 前端-07 ASP.NET 常用对象
- JavaScript---DOM技术、BOM模型演示、window对象
- javascript与DOM(文档对象模型)
- HTML DOM Window 对象
- HTML DOM Window 对象
- DOM Window 对象
- HTML DOM Window 对象
- Dom-window对象
- DOM之Window对象
- DOM对象之Window
- html dom window对象
- I can 前端-01 HTML
- I can 前端-02 CSS
- I can 前端-04 JavaScript
- Oracle管理表
- 为什么说 IPFS 将会替代 HTTP
- nodejs在windows下的安装配置(使用NVM的方式)
- 【Java File类】创建文件目录并在指定路径创建文件
- Win10子系统Bash安装 Ubuntu安装Katoolin 实现自动安装kali工具
- I can 前端-05 DOM模型与Window对象
- HDU 3697 Selecting courses(贪心)
- cpio打包和压包的方法示例
- 5.6 final关键字
- Fabric自动化部署的简单使用
- wxWidgets教程(16)——wxMenuBar、wxToolBar与wxStatusBar用法
- 论Linux文件系统
- 用两个栈实现队列
- 计算机视觉中,有哪些比较好的目标跟踪算法?(下)