dom-events

Replacement for deprecated `keypress` DOM event

我是研究僧i 提交于 2019-11-28 13:35:49
According to MDN article keypress event is deprecated: But I can't find any information elsewhere on whether we should use this event in a new projects. If we shouldn't, what is the replacement? Could somebody give an insight? Since the event is deprecated, you should avoid using it in new code, and plan on removing it from old code. The W3C specification says this about deprecated features: Features marked as deprecated are included in the specification as reference to older implementations or specifications, but are OPTIONAL and discouraged. Only features which have existing or in-progress

Firefox extension: check if window is minimized

匆匆过客 提交于 2019-11-28 12:37:34
I'm trying to keep track of the state of a Firefox window ("maximized", "minimized", "normal", "fullscreen"; see here ). However, whatever I've tried, I never get to see the minimized event; the others doing fine. For example, if I add listeners to the window such as window.addEventListener("activate", function(event) { dump("activate " + window.windowState + " " + window.screenX + " " + window.screenY + "\n"); }, false); window.addEventListener("deactivate", function(event) { dump("deactivate " + window.windowState + " " + window.screenX + " " + window.screenY + "\n"); }, false); window

JavaScript “this” references wrong object [duplicate]

给你一囗甜甜゛ 提交于 2019-11-28 11:29:55
This question already has an answer here: How to access the correct `this` inside a callback? 10 answers Well, this doesn't really refer to the wrong object, but I do not know how to refer to the correct one. function someObj() { this.someMethod1 = function() { var elementBtn = document.getElementById('myBtn'); elementBtn.onclick = function() { this.someMethod2(); //I want this.someMethod2() to be called //...but it tries to call elementBtn.someMethod2() i believe. }; }; this.someMethod2 = function() { alert('OK'); }; } So when my myBtn is clicked I want someObj.someMethod2() to run. And I

Listen for Events from Browser “Find” Window in JavaScript

耗尽温柔 提交于 2019-11-28 10:12:59
问题 Is there a way to listen for typing into the browser's "find" window in JavaScript? I'd like to be able to reinterpret the search text from JavaScript. What do I need to add an event listener for? 回答1: I don't know of any way you can listen for a find -like event and if that's supported in any browser it sure isn't a portable solution. I also don't know what you're trying to achieve but I think that your best option is to listen for the keyboard events that trigger the find window and attempt

Fire onmouseover event when element is disabled

前提是你 提交于 2019-11-28 09:58:39
I have some controls that I need to disable when users don't have edit priveleges, but are sometimes not wide enough to show the entire text of the selected option element. In which case I've added a tool tip with ASP.NET and the following code ddl.Attributes.Add("onmouseover", "this.title=this.options[this.selectedIndex].title") This works when the control is enabled, but doesn't work when it is disabled. The following alert will not fire when a mouse is over the select element: <select disabled="disabled" onmouseover="alert('hi');"> <option>Disabled</option> </select> See this fiddle . Q :

How to listen to custom events on all windows, bubbling issue?

纵然是瞬间 提交于 2019-11-28 09:57:18
问题 I'm trying to listen to custom event 'peakAhBoo' so I add the event listener to gBrowser and if no gBrowser is present then I add it to aDOMWindow (gist). Code snippet: loadIntoWindow: function (aDOMWindow, aXULWindow) { if (!aDOMWindow) { return; } if (aDOMWindow.gBrowser) { aDOMWindow.gBrowser.addEventListener('peakAhBoo', respondToCustomEvent_peakAhBoo, true); } else { aDOMWindow.addEventListener('peakAhBoo', respondToCustomEvent_peakAhBoo, true); } }, Code to dispatch event: var myEvent =

Is it possible to catch browser's File Open/Save dialog event using Javascript

て烟熏妆下的殇ゞ 提交于 2019-11-28 09:46:56
Using Javascript is it possible to listen for browser's file open/save dialog box event. I want to perform an action when I am notified that the save file dialog box has opened now. Specifically I want to hide a loading spinner when dialog box opens (but this could very well be any other action ) I believe I can do that for a dialog box that I create, not sure if it can be done for the browser's standard dialog box. Any pointers for that would be really helpful. No, there is no event for that. Yes! You can take advantage that most browsers (Tested okay on Chrome, Firefox, and IE) fire the

Website does not recognize my inputs [how to fire IE dom event manually from VBA]

ぐ巨炮叔叔 提交于 2019-11-28 08:24:15
I woud like to buy on gdax automatically. But my inputs in the Amount window doesn´t get recognized. I can see that on the little field, that says: Total (LTC) ≈ 0.00000000 My code: Sub test() Dim ObjIE As New InternetExplorer Dim Ohtml As HTMLDocument Dim HTMLtags As IHTMLElementCollection Dim HTMLtag As IHTMLElement Dim HTMLobjekt As IHTMLElement Dim item_limit As Object Dim y As Integer With ObjIE .Visible = True .navigate "https://www.gdax.com/trade/LTC-EUR" Do Until .readyState = READYSTATE_COMPLETE: Loop Set Ohtml = .document End With 'Amount Do Set HTMLtags = Ohtml

How to prevent the double-click select text in Javascript

百般思念 提交于 2019-11-28 08:01:31
问题 Say I have an ul ( li ) list in the page: <ul> <li>xxx<li> <li>xxx<li> </ul> The element li are clickable and double-clickable, they are attached with these events, and I return false in both of them. $('ul li').on('click',function(){ //do what I want return false; }).on('dblclick',function(){ //do what I want return false; }); But when the user double-clicks the element, the text inside the li will be selected. How can this be prevented? Update: Solved now,I use the following code with the

How to know when an DOM element moves or is resized

我的梦境 提交于 2019-11-28 07:20:29
I'd like to know if there is a DOM event to listen for that tells me when a DOM element moves is repositioned or is resized on the page. I am not talking about an elements being drag/dropped. An example is if a have a list of three items on a page, and I use JS to remove one of the top two list items from the page (or hide it or whatever), I'd like to attach a handler to run when the third list item gets moved up in the page. I am using jQuery, so plain javascript or jQuery answers are acceptable. Maybe there are no move/position/resize events at the element level, so if there is a page/doc