[JavaScript] JS通过ajax方法获取指定url的head信息的指定字段值 →→→→→进入此内容的聊天室

来自 , 2021-01-06, 写在 JavaScript, 查看 124 次.
URL http://www.code666.cn/view/865bf464
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. function loadXMLDoc(url)
  6. {
  7. var xmlhttp;
  8. if (window.XMLHttpRequest)
  9.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  10.   xmlhttp=new XMLHttpRequest();
  11.   }
  12. else
  13.   {// code for IE6, IE5
  14.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  15.   }
  16. xmlhttp.onreadystatechange=function()
  17.   {
  18.   if (xmlhttp.readyState==4 && xmlhttp.status==200)
  19.     {
  20.     document.getElementById('p1').innerHTML="Last modified: " + xmlhttp.getResponseHeader('Last-Modified');
  21.     }
  22.   }
  23. xmlhttp.open("GET",url,true);
  24. xmlhttp.send();
  25. }
  26. </script>
  27. </head>
  28. <body>
  29.  
  30. <p id="p1">The getResponseHeader() function is used to return specific header information from a resource, like length, server-type, content-type, last-modified, etc.</p>
  31. <button onclick="loadXMLDoc('ajax_info.txt')">Get "Last-Modified" information</button>
  32.  
  33. </body>
  34. </html>
  35.  
  36. //javascript/8180

回复 "JS通过ajax方法获取指定url的head信息的指定字段值"

这儿你可以回复上面这条便签

captcha