Some properties and methods of the window object in js (location, history, Navigator)

  1. window object:

    方法
        Prompt():显示提示用户输入
        Confirm():带有一段确定按钮与取消按钮的对话框,点击确认按钮返回true,点击取消返回false;
        setInterval();第一个参数是要调用的函数,第二个参数是隔多久时间调用函数一次(无限执行)
        Settimeout();第一个参数是要执行的函数,第二个参数是延时调用(只执行一次);
        Window.Close():关闭当前页面;
        Window.open(“页面地址”,”_self或者_blank”):
        clearInterval():参数是设置定时器的返回值;清除定时器
        Cleartimeout():参数是设置延时器的返回值;清除延时器
    
  2. Location object:

    Location.href=”路径”;页面跳转
    Location.reload();刷新页面
    
  3. screen object:

    Screen.width:获取显示器的宽度
    Screen.height:获取显示器的高度
    Screen.availwidth:可用宽度;相当于body的宽度
    Screen.availheight:可用高度;相当于body的高度
    
  4. Navigator object

    Navigator.appversion:浏览器平台开始的版本信息
    
  5. History object:

    History.back();回到上一个页面;
    History.forward();前进到下一个页面
    History.go(number)当number为负数时,向后跳转几个页面;为正数时,前进几个页面
    

    Note that: The
    History object contains URLs visited by the user (in the browser window). The History object is part of the window object and can be accessed through the window.history property. History object description History object was originally designed to represent the browsing history of the window. However, for privacy reasons, the History object no longer allows scripts to access actual URLs that have already been visited. The only functions that remain in use are the back(), forward() and go() methods.
    Example:
    The following line of code performs the same operation as clicking the back button:
    history.back()
    The following line of code performs the same operation as clicking the back button twice:
    history.go(-2)

Guess you like

Origin blog.csdn.net/weixin_49549509/article/details/109061801