KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm working on a bookmarklet which will let users to write on any input fields in our language. We choose Ctrl+M for switching layout between default and our language (Inspired by Wikipedia). It was working fine in almost every website with chrome. When we started checking with Firefox we found that it only fails in Facebook . Moreover, Facebook catches the Ctrl+M from outside the window scope. Like, form the address bar, search bar, firebug console, etc. I've tried with raw javascript, jQuery and also with the jQuery Hotkeys plugin by John Resig but no luck :( Here is a version that I had tried. You can run it on your Firebug console for testing purpose - (function(){ var noConflictMode = false; if(typeof $ !== 'undefined') noConflictMode = true; if(typeof jQuery === 'undefined') { var root = (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]); var ns = document.createElementNS && document.documentElement.namespaceURI; var script = ns ? document.createElementNS(ns, 'script') : document.createElement('script'); script.type = 'text/javascript'; script.onreadystatechange = function () { if (this.readyState == 'complete') test(); } script.onload= test; script.src= 'https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.min.js'; root.appendChild(script); } else { test(); } function test() { if(noConflictMode) jQuery.noConflict(); jQuery(window).on('keydown keyup keypress', function(e){ e.preventDefault(); // For Firefox e.stopPropagation(); // Extra eff
Tags (comma-separated)
Save Edits
Cancel