Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Javascript in firefox question

  • 16-04-2004 09:55AM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 4,666 ✭✭✭Imposter


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

    Will look into document.all


  • Registered Users, Registered Users 2 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