javascript-events

Event handler not working in Internet Explorer

拥有回忆 提交于 2019-12-12 18:48:49
问题 I am creating a website using JavaScript. The purpose of the JS part is to attach my own keyboard handler to certain text fields. I managed to narrow down the problem to the code as simple as this fiddle: http://jsfiddle.net/k9s3n/1/ In Firefox, Opera and Chrome, typing a character in any of the three fields results in displaying an alert box with the key code. In Internet Explorer (IE8 in my case, that's the lowest version I usually support), however, only input3 works properly - that is, it

Check if INSERT mode is ON when typing in an input

喜你入骨 提交于 2019-12-12 18:42:49
问题 I'm trying to calculate the value of an input field on various events regardless of the event caught. I'm taking into account the events keypress keyup keydown cut paste events (Do I forget anything?). I'm trying to determine if the text-input INSERT mode is on (default - on), or off. I cannot determine the mode by capturing a key event of that key, though I don't know what was the initial state. Does anyone know a way? Preferably - a cross browser solution that includes IE8+, Chrome and FF.

Adding keylistener and using javascript to click a link in Greasemonkey

浪尽此生 提交于 2019-12-12 18:38:22
问题 I want to create a greasy monkey script , which will add a shortcut key for logout action in one mail site. Currently the logout link "?logout&hl=en" which have an id=":r5" . I am able to get the node for the link but not able to call click on it. I tried the script as following function key_event(event){ GM_log("Hello"); GM_log(event.keyCode); //if(event.keyCode != 112) return; e=document.getElementById(':r5'); if(!e) {return;} var evObj = document.createEvent('MouseEvents'); evObj

On Key Up vs On Change with AJAX queries: which is better?

匆匆过客 提交于 2019-12-12 18:14:58
问题 I'm sending POST data from text boxes to a PHP page for processing. Rather than the user clicking a save button, AJAX is used on text box events. I'm torn between using onChange or onKeyUp. OnKeyUp requires more processing on server, because for every key press my script has to access the database and make the change. Server performance could be an issue. OnChange is preferred, as it only sends the changes when the user has finished on the box. However, there is a problem that if the use does

jQuery focusout event doesn't trigger on table element

北慕城南 提交于 2019-12-12 18:09:18
问题 I'm trying to make a table support multiple row selection (for the moment just the CTRL + mouseclick combination). Everything works fine, but when I click outside the table area, the rows don't deselect. Unfortunately, I have found out that the focusout event doesn't trigger at all. Here's my code: $(".library tbody tr").live('click', function (event) { event.preventDefault(); if (event.ctrlKey) { $(this).toggleClass('selected-row'); } else { $(".library tbody tr").removeClass("selected-row")

Making a link stay active displaying hover effect upon click using javascript

时光怂恿深爱的人放手 提交于 2019-12-12 17:22:06
问题 I am struggling to make this work...I've been working on it for hours upon hours now and cannot figure it out. I'd like to make it where if O.F. is clicked, the hover state stays active, if another link is clicked, for example, Founders, the hover state that was active on O.F. disappears and the hover state stays active on Founders. Where am I going wrong? HTML: <div id="profile_list"> <h2>Members: 37</h2> <a href="#Original_Founder" class="panel">• O.F.</a> <a href="#Founder" class="panel">•

jQuery.bind(“remove”)

不打扰是莪最后的温柔 提交于 2019-12-12 16:16:08
问题 Is there a way have an event handler run when a dom element is removed? I have not seen this documented anywhere. It seems it mightt be possible since jQuery is able to remove data and events on element removal. 回答1: Binding DOMNodeRemoved will allow for you to detect removal of nodes inside the bound element. Works in Firefox, Iron and Opera... but not IE. jQuery $("#detectchanges").bind("DOMNodeRemoved",function(){ alert('Something inside of detectchanges was terminated.'); }); $("#clickme"

Normalizing the CodeMirror OnKeyEvent with jQuery

爱⌒轻易说出口 提交于 2019-12-12 16:15:15
问题 I'm using CodeMirror along with jQuery to provide syntax highlighting on a pet PoC project. It's been doing great, until I realized that CodeMirror seems to be capturing key press events on the DOM in such a way that it stops global application hotkeys from working when I'm currently typing into a CM-enabled textarea. For simplicity's sake, let's assume that I have the following listener on my page: var hotkey = function (e) { if (e.shiftKey) { alert('foo'); } }; $(document).keypress(hotkey);

javascript - retrieving html control by specifying coordinates

一世执手 提交于 2019-12-12 16:04:51
问题 how can i get the id of a html control just by specifying the coordinates of a triggered event (like onmousedown, onmouseup, onclick, etc..). the coordinates can be got by e.clientX , e.clientY where e is the event object. the idea is to get the id of control on which a click event is done without having any onClick event in that control's definition. this will dispense the need of specifying the onClick event for multiple controls. 回答1: I do not believe that this is possible, but fortunately

Attaching events in JavaScript

ぐ巨炮叔叔 提交于 2019-12-12 14:48:09
问题 As comment to one of the questions here a commenter wrote (emphasis mine): ... By using an inline "onclick" you are doing a similar thing, but it is harder to maintain and more prone to issues. The JavaScript community as a whole has been moving away from inline JavaScript for a while now. This was referring to attaching events to HTML elements using $("#someID").click(function(){ do something here...; }); rather than <a id="someID" onclick="someFunction();"> Has there really been a shift