zoukankan      html  css  js  c++  java
  • JS学习记录(BOM部分)

     

     BOOM部分

    Screen

    <html lang="en"> <head> <meta charset="UTF-8"> <title>Screen</title> </head> <body> </body> <script> console.log(screen.width); console.log(screen.height); console.log(screen.availWidth); console.log(screen.availHeight); </script> </html>

    结果图:

    Location

    <html lang="en"> <head> <meta charset="UTF-8"> <title>Location</title> </head> <body> <button onclick="assign()">加载新页面</button> <button onclick="replace()">替换页面</button> <button onclick="reload1()">刷新当前页面</button> <button onclick="reload2()">彻底刷新当前页面</button> </body> <script> function assign() { /*可以返回老页面*/ location.assign("http://www.baidu.com"); } function replace() { /*不能返回老页面*/ location.replace("http://www.baidu.com"); } function reload1() { location.reload(); } function reload2() { location.reload(true); } </script> <!--<script> console.log(location.href);/*完整的url*/ console.log(location.protocol);/*协议*/ console.log(location.port);/*端口号*/ console.log(location.hostname);/*主机名称*/ console.log(location.pathname);/*路径名称*/ console.log(location.search);/*?后的数据部分*/ </script>--> </html>

    结果图:

    History对象
    <html lang="en"> <head> <meta charset="UTF-8"> <title>History对象</title> </head> <body> <a href="Demo40.html">Demo40</a> <button onclick="forward()">下一个页面</button> </body> <script src="../../js/history.js"></script> </html>

    结果图:

    Navigator对象
    <html lang="en"> <head> <meta charset="UTF-8"> <title>Navigator</title> </head> <body> </body> <script> console.log(navigator.appName); console.log(navigator.appVersion); console.log(navigator.userAgent); console.log(navigator.platform); </script> </html>
    定时器
    <html lang="en"> <head> <meta charset="UTF-8"> <title>定时器</title> </head> <body> <button onclick="show()">五秒后显示HelloWord</button> <button onclick="cancelShow()">取消显示HelloWord</button> <button onclick="cancelShow2()">停止显示HelloWord</button> </body> <script> // setTimeout 默认情况下,只会执行一次。 var hello; function show() { hello = setTimeout(function () { alert("HelloWord!"); }, 500); } function cancelShow() { clearTimeout(hello); } </script> <!--<script> // setInterval 根据指定的时间,循环执行。 var hello2 = setInterval(function () { console.log("HelloWord!"); }, 1000); function cancelShow2() { clearTimeout(hello2); } </script>--> </html>

    结果图:

    confirm(对话框中显示的纯文本)

    <html lang="en"> <head> <meta charset="UTF-8"> <title>confirm(对话框中显示的纯文本)</title> </head> <body> </body> <script> var flag=confirm("确认样删除此信息吗?"); if(flag){ alert("删除成功"); } else { alert("你取消了删除"); } /*注意confirm与prompt和alert的区别*/ </script> </html>

    结果图:

  • 相关阅读:
    设置java.library.path的值(Mac/Linux/Windows)
    英特尔老款CPU支持虚拟化对照表(转)
    长城小主机GW1等型号进BIOS的设置方法
    Mac 10.12允许任何来源
    DDos与CC攻击的简单个人理解
    Mac 10.12下iTerm2使用lrzsz上传下载文件
    Mac 10.12连接iSCSI硬盘软件iSCSI Initiator X
    华为S5300系列交换机V100R005SPH021升级补丁
    华为S5300系列交换机V100R005SPH020升级补丁
    华为S5300系列交换机V100R006SPH019升级补丁
  • 原文地址:https://www.cnblogs.com/lizuowei/p/7282678.html
Copyright © 2011-2022 走看看