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

How to get HTTP information in the navigation bar through JavaScript

一个新手
Release: 2017-10-10 10:03:45
Original
1441 people have browsed it


  • The annotated part in style is to obtain the information in HTTP

  • The display effect in body is:

    • When you click OK, the information will be deleted

    • When you click Cancel, the information will not be deleted

    • When opening the page, an input prompt box will pop up automatically

    • When you click delete, a warning box will pop up

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

The above is the detailed content of How to get HTTP information in the navigation bar through JavaScript. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!