当前位置:Gxlcms > JavaScript > javascriptWindow及document对象详细整理_基础知识

javascriptWindow及document对象详细整理_基础知识

时间:2021-07-01 10:21:17 帮助过:21人阅读

一、Window对象
  -------------------------------------------------- -------------------   
  对象属性
  window //窗户自身
  window.self //引用本窗户window=window.self
  window.name //为窗户命名
  window.defaultStatus //设定窗户状态栏信息
  window.location //URL地址,配备布置这个属性可以打开新的页面
  -------------------------------------------------- -------------------
  对象方法
  window.alert("text") //提示信息会话框
  window.confirm("text") //确认会话框
  window.prompt("text") //要求键盘输入会话框
  window.setIntervel("action",time) //每一隔指定的时间(毫秒)就执行一次操作
  window.clearInterval() //清除时间配备布置作用就是终止轮回
  window.setTimeout(action,time) //隔了指定的时间(毫秒)执行一次操作
  window.open() //打开新的窗户
  window.close() //关闭窗户
  -------------------------------------------------- -------------------
  成员对象
  window.event
  window.document //见document对象详解
  window.history
  window.screen
  window.navigator
  window.external
  -------------------------------------------------- -------------------
  window.history对象
  window.history.length //浏览过的页面数
  history.back() //撤退退却
  history.forward() //进步
  history.go(i) //前进或头退到历史记录的第i个页面
  //i>0进步,i<0撤退退却
  -------------------------------------------------- -------------------
  window.screen对象
 window.screen.width //屏幕宽度
  window.screen.height //屏幕高度
  window.screen.colorDepth //屏幕色深
  window.screen.availWidth //可用宽度
  window.screen.availHeight //可用高度(除去任务栏的高度)
  -------------------------------------------------- -------------------
  window.external对象
  window.external.AddFavorite("地址","标题" ) //把网站新增到保藏夹
  -------------------------------------------------- -------------------
  window.navigator对象
  window.navigator.appCodeName //浏览器代码名
  window.navigator.appName //浏览器步伐名
  window.navigator.appMinorVersion //浏览器补钉版本
  window.navigator.cpuClass //cpu类型 x86
  window.navigator.platform //操作体系类型 win32
  window.navigator.plugins
  window.navigator.opsProfile
  window.navigator.userProfile
  window.navigator.systemLanguage //客户体系语言 zh-cn简体中文
  window.navigator.userLanguage //用户语言,同上
  window.navigator.appVersion //浏览器版本(包括 体系版本)
  window.navigator.userAgent
  window.navigator.onLine //用户否在线
  window.navigator.cookieEnabled //浏览器是否撑持cookie
  window.navigator.mimeTypes
  ==================================================

二、document对象

对象属性:
document.title //设置文档标题等价于HTML的标签 <BR>document.bgColor //设置页面背景色 <BR>document.fgColor //设置前景色(文本颜色) <BR>document.linkColor //未点击过的链接颜色 <BR>document.alinkColor //激活链接(焦点在此链接上)的颜色 <BR>document.vlinkColor //已点击过的链接颜色 <BR>document.URL //设置URL属性从而在同一窗口打开另一网页 <BR>document.fileCreatedDate //文件建立日期,只读属性 <BR>document.fileModifiedDate //文件修改日期,只读属性 <BR>document.fileSize //文件大小,只读属性 <BR>document.cookie //设置和读出cookie <BR>document.charset //设置字符集 简体中文:gb2312 <BR>---------------------------- <br><br>常用对象方法 <br><br>document.write() //动态向页面写入内容 <BR>document.createElement(Tag) //创建一个html标签对象 <BR>document.getElementById(ID) //获得指定ID值的对象 <BR>document.getElementsByName(Name) //获得指定Name值的对象 <BR>document.body.appendChild(oTag) <br><br>body-主体子对象 <br><br>document.body //指定文档主体的开始和结束等价于<body></body> <BR>document.body.bgColor //设置或获取对象后面的背景颜色 <BR>document.body.link //未点击过的链接颜色 <BR>document.body.alink //激活链接(焦点在此链接上)的颜色 <BR>document.body.vlink //已点击过的链接颜色 <BR>document.body.text //文本色 <BR>document.body.innerText //设置<body>...</body>之间的文本 <BR>document.body.innerHTML //设置<body>...</body>之间的HTML代码 <BR>document.body.topMargin //页面上边距 <BR>document.body.leftMargin //页面左边距 <BR>document.body.rightMargin //页面右边距 <BR>document.body.bottomMargin //页面下边距 <BR>document.body.background //背景图片 <BR>document.body.appendChild(oTag) //动态生成一个HTML对象 <BR>常用对象事件 <br><br>document.body.onclick="func()" //鼠标指针单击对象是触发 <BR>document.body.onmouseover="func()" //鼠标指针移到对象时触发 <BR>document.body.onmouseout="func()" //鼠标指针移出对象时触发 <BR>location-位置子对象 <BR>document.location.hash // #号后的部分 <BR>document.location.host // 域名+端口号 <BR>document.location.hostname // 域名 <BR>document.location.href // 完整URL <BR>document.location.pathname // 目录部分 <BR>document.location.port // 端口号 <BR>document.location.protocol // 网络协议(http:) <BR>document.location.search // ?号后的部分 <br><br>常用对象事件 <BR>documeny.location.reload() //刷新网页 <BR>document.location.reload(URL) //打开新的网页 <BR>document.location.assign(URL) //打开新的网页 <BR>document.location.replace(URL) //打开新的网页 <BR>======================================================================== <BR>selection-选区子对象 <BR>document.selection <BR>======================================================================== <BR>images集合(页面中的图象): <BR>---------------------------- <BR>a)通过集合引用 <BR>document.images //对应页面上的<img>标签 <BR>document.images.length //对应页面上<img>标签的个数 <BR>document.images[0] //第1个<img>标签 <BR>document.images[i] //第i-1个<img>标签 <BR>---------------------------- <BR>b)通过nane属性直接引用 <BR><img name="oImage"> <BR>document.images.oImage //document.images.name属性 <BR>---------------------------- <BR>c)引用图片的src属性 <BR>document.images.oImage.src //document.images.name属性.src <BR>---------------------------- <BR>d)创建一个图象 <BR>var oImage <BR>oImage = new Image() <BR>document.images.oImage.src="https://img.gxlcms.com/https://img.gxlcms.com/1.jpg" <BR>同时在页面上建立一个<img>标签与之对应就可以显示 <BR>---------------------------- <BR>示例代码(动态创建图象): <BR><html> <BR><img name=oImage> <BR><script language="javascript"> <BR>var oImage <BR>oImage = new Image() <BR>document.images.oImage.src="https://img.gxlcms.com/https://img.gxlcms.com/1.jpg" <BR></ script> <BR></html> <br><br><html> <BR><script language="javascript"> <BR>oImage=document.caeateElement("IMG") <BR>oImage.src="https://img.gxlcms.com/https://img.gxlcms.com/1.jpg" <BR></ script> </div> <div class=""> <ul class="m-news-opt fix"> <li class="opt-item"> <a href='/JavaScript-227029.html' target='_blank'><p>< 上一篇</p><p class="ellipsis">基于jQuery的试卷自动排版系统实现代码_jquery</p></a> </li> <li class="opt-item ta-r"> <a href='/JavaScript-227031.html' target='_blank'><p>下一篇 ></p><p class="ellipsis">jQueryUI的Dialog无法提交问题的解决方法_jquery</p></a> </li> </ul> </div> </div> </div> <div class="g-title fix"> <h2 class="title-txt">人气教程排行</h2> </div> <div class="m-rank u-dashed mb40"> <ul> <li class="rank-item"> <a href="/JavaScript-60002.html" title='vue2 设置router-view默认路径的实例' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">213次</span> <span class="g-sort-num top">1</span> vue2 设置router-view默认路径的实例 </a> </li> <li class="rank-item"> <a href="/JavaScript-56926.html" title='Vue-路由导航菜单栏的高亮设置方法' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">213次</span> <span class="g-sort-num second">2</span> Vue-路由导航菜单栏的高亮设置方法 </a> </li> <li class="rank-item"> <a href="/JavaScript-56852.html" title='基于Axios 常用的请求方法别名(详解)' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">213次</span> <span class="g-sort-num third">3</span> 基于Axios 常用的请求方法别名(详解) </a> </li> <li class="rank-item"> <a href="/JavaScript-39788.html" title='JavaScript+canvas实现七色板效果实例' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">213次</span> <span class="g-sort-num ">4</span> JavaScript+canvas实现七色板效果实例 </a> </li> <li class="rank-item"> <a href="/JavaScript-281548.html" title='实现vuex的初始化方法' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">212次</span> <span class="g-sort-num ">5</span> 实现vuex的初始化方法 </a> </li> <li class="rank-item"> <a href="/JavaScript-238997.html" title='jQuery:当鼠标快速移动时无法触发mouseleave事件的问题解决' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">212次</span> <span class="g-sort-num ">6</span> jQuery:当鼠标快速移动时无法触发mouseleave事件的问题解决 </a> </li> <li class="rank-item"> <a href="/JavaScript-234597.html" title='Array.slice()与Array.splice()的返回值类型_基础知识' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">212次</span> <span class="g-sort-num ">7</span> Array.slice()与Array.splice()的返回值类型_基础知识 </a> </li> <li class="rank-item"> <a href="/JavaScript-60647.html" title='微信小程序使用swiper组件实现层叠轮播图' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">212次</span> <span class="g-sort-num ">8</span> 微信小程序使用swiper组件实现层叠轮播图 </a> </li> <li class="rank-item"> <a href="/JavaScript-57684.html" title='element-ui 限制日期选择的方法(datepicker)' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">212次</span> <span class="g-sort-num ">9</span> element-ui 限制日期选择的方法(datepicker) </a> </li> <li class="rank-item"> <a href="/JavaScript-57417.html" title='vue-baidu-map 进入页面自动定位的解决方案(推荐)' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">212次</span> <span class="g-sort-num ">10</span> vue-baidu-map 进入页面自动定位的解决方案(推荐) </a> </li> <li class="rank-item"> <a href="/JavaScript-54331.html" title='JS实现元素上下左右移动效果' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">212次</span> <span class="g-sort-num ">11</span> JS实现元素上下左右移动效果 </a> </li> <li class="rank-item"> <a href="/JavaScript-32878.html" title='node.js中的emitter.on方法使用说明' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">212次</span> <span class="g-sort-num ">12</span> node.js中的emitter.on方法使用说明 </a> </li> <li class="rank-item"> <a href="/JavaScript-251986.html" title='在js中如何实现图片左右滑动' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">211次</span> <span class="g-sort-num ">13</span> 在js中如何实现图片左右滑动 </a> </li> <li class="rank-item"> <a href="/JavaScript-65218.html" title='layui button 按钮弹出提示窗口,确定才进行的方法' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">211次</span> <span class="g-sort-num ">14</span> layui button 按钮弹出提示窗口,确定才进行的方法 </a> </li> <li class="rank-item"> <a href="/JavaScript-53968.html" title='深入理解Vue生命周期、手动挂载及挂载子组件' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">211次</span> <span class="g-sort-num ">15</span> 深入理解Vue生命周期、手动挂载及挂载子组件 </a> </li> <li class="rank-item"> <a href="/JavaScript-32108.html" title='JS 使用for循环遍历子节点查找元素' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">211次</span> <span class="g-sort-num ">16</span> JS 使用for循环遍历子节点查找元素 </a> </li> <li class="rank-item"> <a href="/JavaScript-286609.html" title='bootstrap如何设置表单必填' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">210次</span> <span class="g-sort-num ">17</span> bootstrap如何设置表单必填 </a> </li> <li class="rank-item"> <a href="/JavaScript-286358.html" title='bootstrap4兼容哪些浏览器' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">210次</span> <span class="g-sort-num ">18</span> bootstrap4兼容哪些浏览器 </a> </li> <li class="rank-item"> <a href="/JavaScript-247980.html" title='jQuery实现追加数组并去重功能' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">210次</span> <span class="g-sort-num ">19</span> jQuery实现追加数组并去重功能 </a> </li> <li class="rank-item"> <a href="/JavaScript-215560.html" title='jQuery实现的在线答题功能_jquery' class="item-name ellipsis" target="_blank"> <span class="g-art-count fr">210次</span> <span class="g-sort-num ">20</span> jQuery实现的在线答题功能_jquery </a> </li> </ul> </div> </div> </div> <!-- / 教程内容页 --> </div> </div> <!-- 页尾 --> <div class="footer"> 本站所有资源全部来源于网络,若本站发布的内容侵害到您的隐私或者利益,请联系我们删除!</div> <!-- / 页尾 --> <script type="text/javascript" src="/kan/js/read.js"></script> <div style="display:none"> <div class="login-box" id="login-dialog"> <div class="login-top"><a class="current" rel="nofollow" id="login1" onclick="setTab('login',1,2);" >登录</a></div> <div class="login-form" id="nav-signin"> <!-- <div class="login-ico"><a rel="nofollow" class="qq" id="qqlogin" target="_blank" href="/user-center-qqlogin.html"> QQ </a></div> --> <div class="login-box-form" id="con_login_1"> <form id="loginform" action="/user-center-login.html" method="post" onsubmit="return false;"> <p class="int-text"> <input class="email" id="username" name="username" type="text" value="用户名或Email" onfocus="if(this.value=='用户名或Email'){this.value='';}" onblur="if(this.value==''){this.value='用户名或Email';};" ></p> <p class="int-text"> <input class="password1" type="password" id="password" name="password" value="******" onBlur="if(this.value=='') this.value='******';" onFocus="if(this.value=='******') this.value='';" > </p> <p class="int-info"> <label class="ui-label"> </label> <label for="agreement" class="ui-label-checkbox"> <input type="checkbox" value="" name="cookietime" id="cookietime" checked="checked" value="2592000"> <input type="hidden" name="notforward" id="notforward" value="1"> <input type="hidden" name="dosubmit" id="dosubmit" value="1">记住我的登录 </label> <a rel="nofollow" class="aright" href="/user-center-forgetpwd.html" target="_blank"> 忘记密码? </a></p> <p class="int-btn"><a rel="nofollow" id="loginbt" class="loginbtn"><span>登录</span></a></p> </form> </div> <form id="regform" action="/user-center-reg.html" method="post"> <div class="login-reg" style="display: none;" id="con_login_2"> <input type="hidden" name="t" id="t"/> <p class="int-text"> <input id="email" name="email" type="text" value="Email" onfocus="if(this.value=='Email'){this.value='';}" onblur="if(this.value==''){this.value='Email';};"></p> <p class="int-text"> <input id="uname" name="username" type="text" value="用户名或昵称" onfocus="if(this.value=='用户名或昵称'){this.value='';}" onblur="if(this.value==''){this.value='用户名或昵称';};"></p> <p class="int-text"> <input type="password" id="pwd" name="password" value="******" onBlur="if(this.value=='') this.value='******';" onFocus="if(this.value=='******') this.value='';"> </p> <p class="int-text1"><span class="inputbox"> <input id="validate" name="validate" type="text" value="验证码" onfocus="if(this.value=='验证码'){this.value='';}" onblur="if(this.value==''){this.value='验证码';};"> </span><span class="yzm-img"><img src="/user-checkcode-index" alt="看不清楚换一张" id="indexlogin"></p> <p class="int-info"> <label> <input value="" name="agreement" id="agreement" CHECKED="checked" type="checkbox"> 我已阅读<a rel="nofollow" href="/user-center-agreement.html">用户协议</a>及<a rel="nofollow" href="/user-center-agreement.html">版权声明</a></label> </p> <p class="int-btn"><input type="hidden" name="dosubmit"/> <a rel="nofollow" class="loginbtn" id="register"><span>注册</span></a></p> </div> </form> </div> </div> </div> </div> <script type="text/javascript" src="/kan/js/foot_js.js"></script> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?6dc1c3c5281cf70f49bc0bc860ec24f2"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> <script type="text/javascript" src="/layui/layui.js"></script> <script> layui.use('code', function() { layui.code({ elem: 'pre', //默认值为.layui-code about: false, skin: 'notepad', title: 'php怎么实现数据库验证跳转代码块', encode: true //是否转义html标签。默认不开启 }); }); </script> </body> </html>