Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    48
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Window.onload = function FF3

    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:

    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?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Get a copy of firebug, if you don't have one and check the error console to see if there is any error.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    May 2006
    Posts
    48
    Thanks
    1
    Thanked 0 Times in 0 Posts
    it seems like it's disable for security reasons:

    Code:
    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?

  • #4
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    Are you trying to access an external domain? You can't do that with JS (yet).
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •