View Full Version : Window.onload = function FF3

06-26-2009, 06:33 PM

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:

<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);
if (http.status == 200) {
document.location = url;

} else {
alert("Incorrect username and/or password.");
} else{
alert('Incorect use of the httpauthredirect function');
return false;
<H1>Trying to authenticate, please wait</H1>

Can someone help me with this?

06-26-2009, 06:38 PM
Get a copy of firebug (http://getfirebug.com), if you don't have one and check the error console to see if there is any error.

06-26-2009, 06:47 PM
it seems like it's disable for security reasons:

Error: uncaught exception: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: " ... Line: 25"]

is there any idea how to overcome this?

06-26-2009, 06:52 PM
Are you trying to access an external domain? You can't do that with JS (yet).