首页 > web前端 > js教程 > 正文

JavaScript获取导航条中HTTP信息实例分享

小云云
发布: 2018-01-26 11:51:18
原创
1315 人浏览过

本文主要为大家详细介绍了JavaScript如何获取到导航条中HTTP信息,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能帮助到大家。

1、style中带有注释的部分为获取HTTP中的信息

2、body中显示效果为:

1)、打开页面是自动弹出输入提示框
2)、点击删除时,会有警告框弹出

   点击确定时,删除信息
   点击取消时,不删除信息

代码

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
 <title></title>

 <!-- JavaScript代码 -->
 <script>
  //  console.log("URL地址: " + window.location.href);
  //  console.log("主机名: " + window.location.hostname);
  //  console.log("端口: " + window.location.port);
  //  console.log("主机: " + location.host); // 主机名+端口
  //  console.log("协议: " + location.protocol);
  //  console.log("路径: " + location.pathname);

  //  console.log("有效的宽度(单位:像素): " + screen.availWidth);
  //  console.log("有效的高度(单位:像素): " + screen.availHeight);
  //  console.log("每个像素颜色的位数: " + screen.colorDepth);

  //  document.write("官方浏览器代码名的字符串的表示:" + navigator.appCodeName + "<br/>");
  //  document.write("官方浏览器名的字符串的表示:" + navigator.appName + "<br/>");
  //  document.write("用户代理:" + window.navigator.userAgent + "<br/>");
  //  document.write("版本信息:" + window.navigator.appVersion + "<br/>");
  //  document.write("浏览器所在的计算机的平台:" + window.navigator.platform + "<br/>");
  //  document.write("Cookie:" + window.navigator.cookieEnabled + "<br/>");
 </script>
</head>
<body>
<script>
 function remove() {
  var r = confirm("确定要删除吗?");
  console.log(r);
 }

 prompt("您几岁?");
</script>
<table>
 <tr>
  <th>姓名</th>
  <th>年龄</th>
  <th>操作</th>
 </tr>
 <tr>
  <td>张三</td>
  <td>19</td>
  <td><input type="button" value="删除" onclick="return remove();"/></td>
 </tr>
 <tr>
  <td>李四</td>
  <td>18</td>
  <td><input type="button" value="删除" onclick="return remove();"/></td>
 </tr>
 <tr>
  <td>王五</td>
  <td>20</td>
  <td><input type="button" value="删除" onclick="return remove();"/></td>
 </tr>
 <tr style="display: none">
  <td>赵六</td>
  <td>21</td>
  <td><input type="button" value="删除" onclick="return remove();"/></td>
 </tr>
 <tr>
  <td>孙七</td>
  <td>20</td>
  <td><input type="button" value="删除" onclick="return remove();"/></td>
 </tr>
</table>
</body>
</html>
登录后复制

以上是JavaScript获取导航条中HTTP信息实例分享的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!