how to get header information of a website???


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: how to get header information of a website???

Hybrid View

  1. #1
    Join Date
    Aug 2007
    Posts
    1

    how to get header information of a website???

    var req = new XMLHttpRequest();
    req.open('GET', 'http://localhost/gp/index.php', false);
    req.send(null);

    if(req.status == 200) {
    alert(req.getResponseHeader('Content-type'));
    alert(req.getAllResponseHeaders());

    this code is working fine and giving the HEADER information;but if i change the URL and put http://www.google.com, then it is not working.........plzzzz i need help.

  2. #2
    Join Date
    Aug 2007
    Location
    Navi Mumbai
    Posts
    10

    RE: how to get header information of a website???

    Here is the code i tried with. It is running with other url but not with google. There may be some security risk for which you are not getting the result you want.

    <script>
    function xmlhttpPost()
    {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
    self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
    self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('GET', 'http://www.yahoo.com', true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
    if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {
    alert("Successful!");
    }
    }
    self.xmlHttpReq.send();
    }
    xmlhttpPost();
    </script>

    I hope this will help you

Similar Threads

  1. Get response/request Header information
    By tx12345 in forum VB Classic
    Replies: 2
    Last Post: 03-08-2007, 09:57 PM
  2. Replies: 4
    Last Post: 01-11-2007, 08:19 AM
  3. how can I best start a profitable website
    By john moyers M.D., PhD in forum Web
    Replies: 0
    Last Post: 06-04-2002, 10:12 AM
  4. Using VB to Read Tape Header information
    By Edwin Gomez in forum Talk to the Editors
    Replies: 0
    Last Post: 04-26-2002, 01:08 PM
  5. Replies: 3
    Last Post: 03-07-2001, 11:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center