When I am on IE, when I use tab to move my focus to the link and press CTRL+Shift+Enter, I get the page opened in another tab. I want to restrict this behavior on IE and show the message to user like "not supported", please suggest me how to achieve this using javascript.
You can try using keystroke events. On keystroke, alert the user & return false.
Reference :
Disable Shortkeys when Ctrl or Shift clicked`
Related
Any one please help me in controlling the "X" (cancel Button) of alert box in edge browser, Either i have to remove it or i have to get the click event.
By a native dialog-boxes it isn't possible.
Other site you don't need it because the OK button has the same function like the close button in this dialog-box: in both ways the dialog-box will be closed and nothing else.
But if you want to control it you can create your own alert dialog-box. Or you can use some library or framework with custom dialog-boxes.
I have a html which has an input box. I want to use the keyboard to enter some text in the input box and in the debugger I want to see input box's value.
but when I run the debugger with "ctrl+r" , the web page become inactive, so I can't enter.
how can I do that?
To debug, you need to use browser Console window.
To activate console window in chrome, here are few options
Press F12
Right click on your page and choose Inspect option
Press ctrl + shift + i
You will get a develper window, Here choose the console tab.
Once you are here you can write your Javscript/ Jquery (if library is loaded) and debug the values.
To debug Functions or event handlers
Add this keyword debugger; in any line from where you want to debug, Then open up the developer window and then do the activity which will trigger the function execution, The Sources window will stop right at the line where it hits debugger; and from there you can use F10,F11 etc keys to debug.
Look for these options
ctrl + r is for refresh the page , not the debugger.
for debug you need to do one from two options:
1) insert in your code "debbuger;" in the line that you want to stop there
2) put a break point using the chrome developer tools
attach for you link that will help you with all that :
https://developers.google.com/web/tools/chrome-devtools/?utm_source=dcc&utm_medium=redirect&utm_campaign=2016q3
I have come across a wierd situation where i am unable to fire event in Safari using Jquery on click. The thing is for example: i bind on click to a button and alert hello. First time it works. Now i changed the code in js and say something like alert Jello. Now , it only fires the hello, the old code that i wrote. It is not taking my new changed code which should have alerted Jello. Again, when i changed the id of the button and try again, it wokrs the first time and alerts Jello, after that it's old same.
Note that i have tested this same in firefox but no issues, it gets the changes. also i tried with document and window load but no luck. What do you think of this problem ? Any help is appreciated. Thank You.
It sounds like you're getting a cached version of the javascript being brought back. Try a refresh and clear the cache by using one of the following (depending on whether your on a mac or not):
Hold the Ctrl key and press the F5 key.
Hold the ⇧ Shift key and click the Reload button on the navigation
toolbar.
Hold the Ctrl key and click the Reload button on the navigation
toolbar.
Hold the ⇧ Shift key and press the F5 key.
Wikipedia Reference
When user presses Ctrl+F on keyboard, browser shows a find box where user can type some text and browser finds occurrences of that text on the current webpage. I would like to keep this feature, but once my users clicks somewhere on the webpage, for example on a certain input element, I want chrome to cancel the finding - to stop - to hide the find box.
How to do that in JavaScript?
At least in chrome...
I know there is a possibility to intercept all keyboard events and cancel the Ctrl+F keystroke in general so the find bar never appears, but this is not my goal, as I wrote I want this to be preserved, but auto-hide programatically.
I noticed that the find box disappears if navigating away from the webpage, I tried to 'navigate away' by adding a #hash to the location.href but this didn't seem to work. I actually cannot navigate away, but maybe some similar hack could help?
$(window).keypress(function (e) {
return !(e.which == 102 && e.ctrlKey)
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
Using jQuery this code is correctly working in Firefox. But Chrome didn't generate event if you are using Ctrl+F shortcut. And you can't rewrite browser`s behaviors using JS. You can rewrite it if you will write the plugin for browser
I'm using Firefox and I'd like to know how I can determine which function on a site that uses Javascript interrupts the normal operation of Spacebar key, which is supposed to scroll down a whole page (and in combo with Shift scoll up a page), and super-hijack it to work normally. How do I do that?
I don't want to disable Javascript on the whole site or everywhere, so Noscript is not a solution. I'm looking for disabling a single function.
In Chrome:
Open DevTools, choose Sources tab, on the right side expand Event Listener Breakpoints, here you choose Keyboard, and select keyup or keydown. Then use the website, it'll break on keyup or keydown, so you just have to press spacebar to find out where it's handled.
use Jonathan's answer to find what the issue is, but this will, as you call it, "super-hijack" it (probably):
function cancelUtil(e){
e.stopImmediatePropagation();
}
window.addEventListener('keydown',cancelUtil,true);
window.addEventListener('keypress',cancelUtil,true);
window.addEventListener('keyup',cancelUtil,true);