jQuery追加不在其他计算机上工作

时间:2018-05-06 12:12:20

标签: javascript jquery append

我从其他网站获取html,检查特定文本,如果找到特定文本,则想附加一个段落。

问题是,如果我在我的计算机上运行它并在我的网络服务器上测试它,则会附加输出。如果其他人试图从另一台机器上使用我的脚本,脚本不会附加一个新的段落,我不明白为什么。

    <!DOCTYPE html>
  <html>
      <meta charset="UTF-8">
    <head>


    <style>
        .color{color:red}
      </style>
      <script src="https://code.jquery.com/jquery-latest.js"></script>
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    </head>
    <body>


      <h3>Enter Website</h3>
        <input id="input" placeholder="http://example.com" name="input_field">
        <input type="button" id="search" value="SUCHE" onclick="jQuery.get();" />

      <!-- Text will be injected into the id output_gsvo_ready -->
      <h4> Find at website </h4> 
      <div class="a" id="append_cBox"> </div> <br>
      <div id="append_sButton"> </div> <br>
      <div id="append_gAnalytics"> </div> <br>
      <div id="append_gFonts"> </div>
  </body>


  <script>




   jQuery(search).click(function(){
            //Save data from website as mydata
            var mydata = "";
            const website = jQuery("input").val();
            const proxyurl = "https://cors-anywhere.herokuapp.com/";
               //Get and save requested website data 
               jQuery.get(proxyurl + website, function (data) {
                        console.log('data is' + data);
                        mydata = data;

            //Var Program is checking for if existent on website 
            var cookie = document.cookie;
            var shareButton = ('fb-share-button');
            var googleAnalytics = ('function(i,s,o,g,r,a,m)');
            var googleExternalFonts = ('href="https://fonts.googleapis.com/');

            console.log('XXXXXXXXXXXXXX'  + cookie)


             //find content at page and output a paragraph if somethins is found
            // if(cookie.indexOf("wordpress_test_cookie") >= 0) {jQuery('#append_cBox').append('NEIN - Es werden Cookies

abgefragt').attr('class', 'color');};
                if(cookie.indexOf("wordpress_test_cookie") >= 0) {jQuery('#append_cBox').append('<p>NEIN - Es werden Cookies abgefragt</p>').attr('class', 'color');};
                if(mydata.search(shareButton) !== -1) {jQuery('#append_sButton').append('NEIN - Es wurde ein Share button gefunden').attr('class', 'color' );};
                if(mydata.search(googleAnalytics) !== -1) {jQuery('#append_gAnalytics').append('NEIN - Google Analystics gefunden').attr('class', 'color');};
                if(mydata.search(googleExternalFonts) !== -1)  {jQuery('#append_gFonts').append('NEIN - Externe Google-Fonts gefunden').attr('class','color');};           
         });
        });
     </script>
    </html>

如果我在我的机器上试用它,如果在网站上找到了什么,我看起来像这样: Working picture of appending jQuery

0 个答案:

没有答案