Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript in firefox question

Options
  • 16-04-2004 10:55am
    #1
    Registered Users Posts: 4,666 ✭✭✭


    I have just switched to firefox from IE and the following piece of JS won't execute for me. Anyone got any ideas why?
    function openPage(e){
    	if (document.layers){
    		key = e.which;
    	}else if (document.all){
    		key = event.keyCode;
    	}
    		
    	if((key>47 && key<58) 
    		|| (key>96 && key<123)
    		|| key==32 || key==66){
    			
    			var t = eval('destination' + key);
    			if(t != "http://")
    				window.location=t;
    		}	
    }
    document.onkeypress=openPage;
    
    It's supposed to open a page that is assigned to a key. The keypress is recorded and the saved address is loaded in the browser and the page opened.


Comments

  • Closed Accounts Posts: 97 ✭✭rde


    As far as I'm aware document.all is a microsoft creation; it's not in javascript proper. A simple way to check is to type "javascript:" in as the url; it'll pop up a window listing all your javascript errors and should help you narrow down the problem if I'm misremembering my js.


  • Registered Users Posts: 4,666 ✭✭✭Imposter


    I had the JS window open and there were no errors.

    Will look into document.all


  • Registered Users Posts: 1,268 ✭✭✭hostyle


    You need a decent standards-related javascript reference. document.layers is Netscape only (not Mozilla), document.all is IE only. Both return false in firefox. document.onkeypress is also IE only, so your keypress event is not being captured. Have a look at this to get you going you in this specific instance.


Advertisement