zoukankan      html  css  js  c++  java
  • 近期在看的一段JS(谁能看出我想实现什么功能)

    示例代码:

    <script type="text/javascript">
    !function(){
        var e=/([http|https]://[a-zA-Z0-9\_.]+.baidu.com)/gi,
        r=window.location.href,
        o=document.referrer;
        // console.log(e);
        // console.log(r);
        // console.log(o);
        if(!e.test(r)){ // 为了防止 这个网址是百度自家的产品
            // console.log('a');
            var n="//api.share.baidu.com/s.gif";
            o?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);
            var t=new Image;
            t.src=n;
            console.log(t);
        };
        // if(!e.test('http://www.baidu.com/')){
        //     console.log('a');
        // }else{
        //     console.log('b');
        // };
    }(window);
    </script>

    深入探讨:

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    </head>
    <body>
    <a href="http://127.0.0.1/1/1.html">3.html</a>
    <a href="http://127.0.0.1/1/2.html">2.html</a>
    <a href="http://127.0.0.1/1/3.html">1.html</a>
    <a href="http://127.0.0.1/1/4.html">2.html</a> 
    <a href="http://127.0.0.1/1/5.html">1.html</a>
    <a href="http://127.0.0.1/1/6.html">2.html</a> 
    <a href="http://127.0.0.1/1/7.html">2.html</a> 
    <a href="http://127.0.0.1/1/8.html">2.html</a> 
    <a href="http://127.0.0.1/1/9.html">2.html</a> 
    <a href="http://127.0.0.1/1/10.html">2.html</a> 
    <a href="http://127.0.0.1/1/11.html">2.html</a> 
    <a href="http://127.0.0.1/1/12.html">2.html</a> 
    <a href="http://127.0.0.1/1/13.html">2.html</a> 
    <a href="http://127.0.0.1/1/14.html">2.html</a> 
    <a href="http://127.0.0.1/1/15.html">2.html</a> 
    <a href="http://127.0.0.1/1/16.html">2.html</a> 
    <a href="http://127.0.0.1/1/17.html">2.html</a> 
    <a href="http://127.0.0.1/1/18.html">2.html</a> 
    <a href="http://127.0.0.1/1/19.html">2.html</a> 
    <a href="http://127.0.0.1/1/20.html">2.html</a>
    </body>
    <script type="text/javascript">
    var list = document.getElementsByTagName("a");
    var n = "//api.share.baidu.com/s.gif";
    var r = window.location.href;
    var url = [];
    for(var i=0;i<list.length;++i){
        url.push(n+'?r='+encodeURIComponent(list[i].href)+'&l='+r);
    };
    for(var i=0;i<5;++i){
        var t = new Image;
        t.src = url[Math.round(Math.random() * list.length)];
    }; 
    
    // var m = Math.round(Math.random() * list.length);
    // api.share.baidu.com/s.gif?r=http%3A%2F%2F127.0.0.1%2F1%2F3.html&l=http://127.0.0.1/1/3.html
    // api.share.baidu.com/s.gif?r=http%3A%2F%2F127.0.0.1%2F1%2F3.html&l=http://127.0.0.1/2.html
    </script>
    </html>

    谁能看出我想要实现什么功能。

  • 相关阅读:
    221. 最大正方形
    9. 回文数
    2. 两数相加
    1. 两数之和
    HDU 1864 最大报销额
    47 java包打成本地maven
    46 数组中的元素进行位置交换
    5 docker安装kibana
    45 vue图片放大预览
    4 docker中安装es
  • 原文地址:https://www.cnblogs.com/e0yu/p/9992578.html
Copyright © 2011-2022 走看看