Home > Web Front-end > JS Tutorial > body text

Implementation steps of JS operating window object

php中世界最好的语言
Release: 2017-11-28 15:10:24
Original
1787 people have browsed it

Let me introduce to you the property methods of JS operating window object and the implementation steps of JS operating window object. Let’s give you a small case to help you understand. Let’s take a look.

-------------------------------------------------- --------------------------
Note: The name attribute of the element on the page and the name referenced by JavaScript must be consistent including upper and lower case
Otherwise it will Prompt you with an error message "The referenced element is empty or not an object"
-------------------------- -----------------------------------------------
Object properties

window.opener        opener属性与打开该窗口的父窗口相联系,当访问子窗口中operer属性时  ,返回的是父窗口。通过该属性,可以使用父窗口对象中的方法和属性。 
window                     //窗口自身
window.self                //引用本窗口window=window.self
window.closed            //表示窗口是否已经关闭
window.name             //为窗口命名
window.defaultStatus  //设定窗口状态栏信息
window.location         //URL地址,设置这个属性可以打开新的页面
Copy after login

------------------------------------------------ --------------------------
Object Method

window.alert("text")                      //提示信息对话框
window.confirm("text")                  //确认对话框
window.prompt("text")                  //要求键盘输入对话框
window.setIntervel("action",time)    //每隔指定的时间(毫秒)就执行一次操作
window.clearInterval()                    //清除时间设置作用就是终止循环
window.setTimeout(action,time)     //隔了指定的时间(毫秒)执行一次操作
window.open()                            //打开新的窗口
window.close()                            //关闭脚本所在窗口
Copy after login

-------- -------------------------------------------------- ----------
Member Object

window.event
window.document   //见document对象详解
window.history
window.screen
window.navigator
window.external
Copy after login

------------------------ ----------------------------------------
window. history object

window.history.length  //浏览过的页面数
history.back()         //后退
history.forward()      //前进
history.go(i)          //到历史清单的第i位
                       //i>0前进,i<0后退
Copy after login

-------------------------------- -------------------------------------
window.screen object

window.screen.width        //屏幕宽度
window.screen.height       //屏幕高度
window.screen.colorDepth   //屏幕色深
window.screen.availWidth   //可用宽度
window.screen.availHeight  //可用高度(除去任务栏的高度)
Copy after login

---------------------------------------- --------------------------
window.external object

window.external.AddFavorite("地址","标题" )  //把网站添加到收藏夹
Copy after login


- -------------------------------------------------- ------------------
window.navigator object

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
Copy after login

--------- -------------------------------------------------- ----------

<!--window对象方法示例脚本-->
<script language="javascript">   window.alert("您好!")</script>
<script language="javascript">    var action    action=window.confirm("请选择操作...")    if(action)      document.write("您选择了继续操作")    else      document.write("您选择了取消操作")</script>
<script language="javascript">   var info   info=window.prompt("请输入一些必要的信息")   document.write (info)</script>
<script language="javascript">   var i;i=0;   function action(){      i++;      window.alert(i) //监视循环情况      if(i>=10)      window.clearInterval(stop) //终止循环   }   stop=window.setInterval("action()",1000)//1000毫秒=1秒</script>
<script language="javascript">   var i;i=0;   function action(){      i++;      window.alert(i) //监视循环情况   }   window.setTimeout("action()",1000)   //相同的代码setTimeout只执行一次</script></html>
Copy after login


I believe you have mastered the method after reading these cases, and there will be more exciting ones Please pay attention to other related articles on php Chinese website!

Related reading:

How to make DIV adaptive height

##How to use Vue+CSS3 to create interactive effects

How does the front end solve the bug that emoji expressions cannot be sent

The above is the detailed content of Implementation steps of JS operating window object. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template