javascript-events

Javascript onkeypress

青春壹個敷衍的年華 提交于 2019-12-18 09:45:13
问题 I have a question regarding the onkeypress event on Javascript. Is it possible to detect Just Ctl key or Alt Key? At the moment if both Ctl and m are pressed the onkeypress event can trigger a click. Is it possible to do just Ctl key by itself? Looking forward to your comments 回答1: onkeypress just catches character keys. Use onkeydown and/or onkeyup for the other keys. See Peter-Paul Koch on key events. 回答2: From the looks of it, no, you can't just capture the Ctrl key. The hotkeys jQuery

JavaScript & JSP

こ雲淡風輕ζ 提交于 2019-12-18 09:41:57
问题 Firstly, I have done my research and already know that JavaScript = client JSPs = server side. I don't want to waste your time. My situation is that I want to execute JSP code from an event (not from a HTML form). I have a HTML link ( <a href="...">XXX</a> ), which is NOT within <form> tags; it just an ordinary HTML link. Through Javascript, I will be able to get the href value and store it in a hidden input field. Instantly after this, I want to execute request.getAttribute("...") and pass

WYSIWYG editor for IE [closed]

限于喜欢 提交于 2019-12-18 09:40:06
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I want to make a new WYSIWYG editor, in which I have used an Iframe with designmode ON, I Want to do something like - when user selects a text and click an image button the image should be in background of the

Blur event triggered on focus

空扰寡人 提交于 2019-12-18 09:28:55
问题 I am using the following code jsFiddle: function Field(args) { this.id = args.id; this.name = args.name ? args.name : null; this.reqType = args.reqType ? args.reqType : null; this.reqUrl = args.reqUrl ? args.reqUrl : null; this.required = args.required ? true : false; this.error = args.error ? args.error : null; this.elem = document.getElementById(this.id); this.value = this.elem.value; this.elem.addEventListener('blur', this, false); this.elem.addEventListener('focus', this, false); } //

Preventing a callback from executing until input stops

只谈情不闲聊 提交于 2019-12-18 09:01:03
问题 A timer to fire an AJAX call if no key is pressed. If a key is pressed, then abort the last timer and add a new timer. That is what I want to do but failed to success. Here is my code: var t; input.onkeyup = function(){ $('.confirmText').html('Checking...'); var timeStampObj = new Date() var timeStamp = timeStampObj.getTime(); var oldTimeStamp = $(this).attr('timeStamp');//I store a timeStamp in the element if(timeStamp < 500 + oldTimeStamp){ $(this).attr('timeStamp', timeStamp); clearTimeout

event capturing with jQuery

我是研究僧i 提交于 2019-12-18 08:47:28
问题 jQuery uses event bubbling, but is there a way to do event capturing ie in the descending order as explained here The specific case is the following where host A & host B are on the same domain like : www.mydomain.com and xxx.mydomain.com . Of course the Same Origin Policy makes it that it is not possible to trigger on event in the iframe. However I just would like to know if user has clicked on $('#hostA') and pass on the event to the <iframe> . <div id="hostA"> <iframe id="hostB"> </div>

Using e.keyCode || e.which; how to determine the difference between lowercase and uppercase?

限于喜欢 提交于 2019-12-18 08:11:26
问题 I am using e.keyCode || e.which; to determine which key was pressed, but I am getting 65 for both a and A why is this happening and how can I detect the difference between the two? 回答1: just use e.which in jquery. They normalize this value for all browsers. Additionally you can check for e.shiftKey . 回答2: Whether it's 'a' or 'A', 65 is the result of the key pressed on the keyboard and it's always 65 for that key. The event will only specify which key is pressed and not its value; those are

javascript: How Can a parent window know that its child window closed?

依然范特西╮ 提交于 2019-12-18 07:42:28
问题 I want to execute a function when an opened child window is closed. Child window opening code is: outWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=600, height=400, top=100, left=100); i want to call a javascript function written in parent window.I am using YUI-2 for developing the plugin. How can i make it work? what event should be registered? thanks in advance. 回答1: You could do

Disable F5 key in Safari 4

半腔热情 提交于 2019-12-18 07:16:40
问题 I have written the following javascript code to catch F5 key press and prevent the user from refreshing: (I understand this is not a good idea but i am stuck with this whether any one likes it or not. Also the question i ask pertains to why the script below does not work with safari 4 but works for other browsers.) var fn = function (e) { if (!e) var e = window.event; var keycode = e.keyCode; if (e.which) keycode = e.which; var src = e.srcElement; if (e.target) src = e.target; // 116 = F5 if

JavaScript & Events - Best Practice

北慕城南 提交于 2019-12-18 06:39:53
问题 I once read that the following coding technique is considered bad: <a HREF="page.htm" onClick="alert('Hello World')">text link</a> Basically, having these event handlers (like onClick) within the HTML tag is the wrong approach to use. What is the reason for this? What is this "bad" technique called? What is the "proper" way to do this? 回答1: This is an inline event handler attribute . (+1 chjj's answer for alternatives). It's generally considered ‘bad’ for a number of reasons: you're mixing