View Single Post
Old 06-08-2007, 02:20 AM   PM User | #1
DH2006
New Coder

 
Join Date: May 2006
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
DH2006 is an unknown quantity at this point
How to get the links in a responseText/responseXML?

Hi!
How could I find the links (like in document.links[0] ...) from the content i retrieved through a XMLHttpRequest?
I get the error: MyThis.tempObj has no properties.

Code:
<html><head>
<script language="javascript" type="text/javascript">
MyXMLHttpRequest = function(fuURL,fuCallMeOnLoad) {
  var MyThis = this;
  this.status = 0; // siehe http-response-codes bzw xmlgetrequest-response-codes
  this.theURL = fuURL; this.HTMLofURL = ''; this.CallMeOnLoad = fuCallMeOnLoad;
  this.extractedLinks = new Array();
  function onLoad (e)    {
      MyThis.status = 200;
      MyThis.HTMLofURL = e.target.responseText; 
      var tempObj = e.target.responseXML;  //That's not working
          alert(tempObj.links[1]);  // and so this gives an error
//      MyThis.CallMeOnLoad(MyThis.theURL,MyThis.HTMLofURL);
  }
  this.LoadPage = function() {
    try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) {   alert("Permission UniversalXPConnect denied."); }
    var r = new XMLHttpRequest();
    r.onload = onLoad;
    r.open ("GET", this.theURL, true);
    r.send (null);
  }
}
function Show(t,h) {alert(t + "\n" + h);}
var Seite = new MyXMLHttpRequest('http://www.google.com',Show);
Seite.LoadPage();
</script></head><body> Hello! </body></html>
I have tried some other stuff already too, like parser, documentElement, ... but somehow responseXML is not there.

Greetings
Dieter

Last edited by DH2006; 06-08-2007 at 02:23 AM.. Reason: Forgot the line "Seite.LoadPage();"
DH2006 is offline   Reply With Quote