zoukankan      html  css  js  c++  java
  • <JavaScript> 九. BOM其它对象(screen对象, navigator对象, location地址栏对象, history历史记录对象)

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <title></title>
     5 <script type="text/javascript">
     6 
     7 /*
     8     screen 屏幕对象
     9     ------------------- 属性 ---------------------
    10      屏幕宽度
    11     height: 屏幕高度
    12     availWidht: 有效宽度, 不含任务栏
    13     availHeight: 有效高度, 不含任务栏
    14     都是只读属性
    15 */
    16 var str = "<h2>屏幕的尺寸</h2>"
    17 str += "宽度: " + screen.width + ", 高度: " + screen.height + "<br>";
    18 str += "有效宽度: " + screen.availWidth + ", 有效高度: " + screen.availHeight + "<br>";
    19 document.write(str);
    20 document.write("<hr>");
    21 
    22 /*
    23     navigator 浏览器对象
    24     ------------------- 属性 ---------------------
    25     appName: 软件名称
    26     appVersion: 核心版本
    27     systemLanguage: 系统语言
    28     userLanguage: 用户语言
    29     platform: 用户平台
    30 */
    31 var str = "<h2>浏览器信息</h2>";
    32 str += "appName: " + navigator.appName;
    33 str += "<br>appVersion: " + navigator.appVersion;
    34 str += "<br>systemLanguage: " + navigator.systemLanguage;
    35 str += "<br>userLanguage: " + navigator.userLanguage;
    36 str += "<br>platform: " + navigator.platform;
    37 document.write(str);
    38 document.write("<hr>");
    39 
    40 /*
    41     location 地址栏对象
    42     ------------------- 属性 ---------------------
    43     href: 获取完整的地址, 可以实现JS的网页跳转
    44     host: 主机名
    45     hostname: 主机名
    46     pathname: 文件路径及文件名
    47     search: 查询字符串
    48     protocol: 协议 http:// ftp://
    49     hash: 锚点名称 #top
    50     reload(true): 刷新网页, true表示强制刷新
    51 */
    52 // 3秒后跳转百度
    53 // window.setTimeout("location.href = 'http://www.baidu.com'", 3000);
    54 
    55 /*
    56     histroy 历史记录对象
    57     ------------------- 属性 ---------------------
    58     length: 历史记录个数
    59     go(n): 前进n页
    60     go(0): 刷新
    61     go(-n): 后退n页
    62     forward(): 前进
    63     back(): 后退
    64 */
    65 </script>
    66 </head>
    67 <body>
    68 
    69 <!-- 地址栏对象 -->
    70 <input type="button" value="刷新网页" onclick="javascript:location.reload(true)">
    71 <hr>
    72 
    73 <!-- 历史记录对象 -->
    74 <a href="news.html">新闻</a>
    75 <input type="button" value="前进" onclick="history.go(1)">
    76 
    77 </body>
    78 </html>
  • 相关阅读:
    结对-结对编程项目作业名称-结对项目总结
    课后作业 -团队项目编程进度
    团队-象棋游戏-模块开发过程
    团队-象棋游戏-模块测试过程
    结队-结队编程项目作业名称-项目进度
    课后作业-阅读任务-阅读笔记-3
    团队-象棋游戏-需求分析
    团队-象棋游戏-成员简介及分工
    课后作业 -团队项目编程进度
    团队编程 象棋游戏 开发文档
  • 原文地址:https://www.cnblogs.com/ZeroHour/p/6367308.html
Copyright © 2011-2022 走看看