Eben
06-26-2009, 05:33 PM
hi,
i have a short js code that auto login me to password protected http folder,
it seems that the function window.onload = function doesn't work in FF3,
here's the code:
<HTML>
<HEAD>
<SCRIPT language="javascript">
var username='user';
var password='password';
var url='http://secureserver.com/private';
function getHTTPObject() {
if (typeof XMLHttpRequest != 'undefined') {
return new XMLHttpRequest();
}
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
return false;
}
window.onload = function() {
var http = getHTTPObject();
if (http && this.url && this.username && this.password) {
http.open("GET", this.url, false, this.username, this.password);
http.send("");
if (http.status == 200) {
document.location = url;
} else {
alert("Incorrect username and/or password.");
}
} else{
alert('Incorect use of the httpauthredirect function');
}
return false;
}
</SCRIPT>
</HEAD>
<BODY>
<H1>Trying to authenticate, please wait</H1>
</BODY>
</HTML>
Can someone help me with this?
i have a short js code that auto login me to password protected http folder,
it seems that the function window.onload = function doesn't work in FF3,
here's the code:
<HTML>
<HEAD>
<SCRIPT language="javascript">
var username='user';
var password='password';
var url='http://secureserver.com/private';
function getHTTPObject() {
if (typeof XMLHttpRequest != 'undefined') {
return new XMLHttpRequest();
}
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
return false;
}
window.onload = function() {
var http = getHTTPObject();
if (http && this.url && this.username && this.password) {
http.open("GET", this.url, false, this.username, this.password);
http.send("");
if (http.status == 200) {
document.location = url;
} else {
alert("Incorrect username and/or password.");
}
} else{
alert('Incorect use of the httpauthredirect function');
}
return false;
}
</SCRIPT>
</HEAD>
<BODY>
<H1>Trying to authenticate, please wait</H1>
</BODY>
</HTML>
Can someone help me with this?