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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disable Hotkeys for Netscape 6 & 7?

    I'm trying to figure out how to disable certain hotkeys (ctrl + n, ctrl + o, etc...) and i'm having some trouble with netscape 6 and 7 browsers. Heres what i've got right now...

    Code:
    // called onLoad
    function WinOpen () {
    
    	try {
    		netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
    	} catch (err) {
    		document.write("Sorry, you can not enjoy this site because of " + err + ".");
    		return false;
    	}
    
    	window.open("nn_keycode.htm","newWindow","titlebar=no,hotkeys=no");
    }
    
    // code on newly opened window (disabled hotkey window)
    function docKeyDown (event) {
    
    	if(event.ctrlKey && event.keyCode == 78) {
    		alert('ctrl + n hit');
    		event.cancelBubble = true;
    		return false;
    	}
    
    }
    
    document.addEventListener("keydown",docKeyDown,false);
    In this script, i'm detected for <ctrl> + <n> and it successfully detects the hotkey combo (by displaying alertbox), but it also opens up a new browser window, which i don't want.

    Any ideas, or prior experience?

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    <preaching>Trying to stop the user from opening a new window is really bad behavior from a website and should be avoided. A website is intended to be a document, not an application - and a document shouldn't be able to disable or even change any portion of the user interface. Some things in the user interface already can't be changed or stopped, even if they can be detected - and while detection might be good, changing really isn't.

    In short, don't even try to do that. You can't prevent it from a user who knows the system anyway, and most mozilla users aren't just Joe Average when it comes to computer skills - it's a browser popular among web designers, scripters, programers and other computer circles.

    </preaching>

    Well, the fact is, I believe you can't override most of the user interface features, such as opening a new window, opening the DOM Inspector etc. That is, from my point of view, the way things are supposed to be. If you're making an application, try XUL.
    Last edited by liorean; 04-07-2003 at 09:20 PM.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    New to the CF scene
    Join Date
    Apr 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you, but i know the ramifications of what i am tring to do and it has nothing to do with a public website.

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Well, I'm sorry to say, but you'll remain limited by the rules that apply to websites even if you have an application, if you're running it as html. A xul/xbl interface to load the html document should be able to access some more features, probably also change key binding. I don't know if that's a viable solution to you, though.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #5
    New to the CF scene
    Join Date
    Apr 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well i figured it out anyway...instead of this...
    Code:
    document.addEventListener("keydown",docKeyDown,false);
    this worked for me...
    Code:
    document.addEventListener("keypress",docKeyDown,false);
    keypress instead of keydown.

    Dispite what you think *should* happen with the behavior of a browser liorean, certain characteristics like this are allowed, with user permission or signed scripts...maybe you should read up on that.


  •  

    Posting Permissions

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