Hello!
How to pass a function- or variable-reference to the xmlhttprequest-onload-event? The function and the variable are part of an object genereated with “tempObj = new Seite(…)” .
Edit: I should add, that this will only running locally on Firefox.
Here is an example-page:
[CODE]<html>
<head>
<title>Why are the lines marked by “//<===” not working? How to pass that function call to the function onLoad?</title>
<script language=”javascript” type=”text/javascript”>
Seite = function(fuURL,fuText) {
this.status = 0; this.theURL = fuURL; this.myId = fuText;
this.HTMLofURL = ‘placeholder-text’;
function callMeFromOnLoad(aURL,aHTMLsource) { alert(this.myId); }
function onLoad (e) {
this.HTMLofURL = e.target.responseText; //<=== “this.HTMLofURL” will actually not be the “this.HTMLofURL” as two lines above, when called from the
// XMLHttoRequest onload-event ):
testAlert(this.theURL + “nn” + this.HTMLofURL); // “this.theURL” isn’t the same as the “this.theURL” from above
this.callMeFromOnLoad(this.theURL,this.HTMLofURL); //<=== same here
}
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 testAlert(fuText) { alert(fuText);}
function testSearch() {
var tempObj;
tempObj = new Seite(‘http://www.google.com’,’TestObj1′);
tempObj.LoadPage();
}
</script>
</head>
<body onLoad=”testSearch();”>
Hello
<pre>
How to pass a function- or variable-reference to the xmlhttprequest-onload-event? The function and the variable are part of an object genereated with “tempObj = new Seite(…)” .
Why are the lines marked by “//<===” not working? How to pass that function call to the function onLoad?
this.HTMLofURL = e.target.responseText; //<=== “this.HTMLofURL” will actually not be the “this.HTMLofURL” as two lines above, when called from the
// XMLHttoRequest onload-event ):
testAlert(this.theURL + “nn” + this.HTMLofURL); // “this.theURL” isn’t the same as the “this.theURL” from above
this.callMeFromOnLoad(this.theURL,this.HTMLofURL); //<=== same here
</pre>
<span id=”id:forFastOutput”></span>
</body></html>