dom-events

How do I add and remove an event listener using a function with parameters?

一曲冷凌霜 提交于 2019-12-03 14:38:43
问题 Sorry if this is a common question, but I couldn't find any answers that seemed pertinent through searching. If I attach an event listener like this: window.addEventListener('scroll', function() { check_pos(box); }, false); it doesn't seem to work to try to remove it later, like this: window.removeEventListener('scroll', function() { check_pos(box); }, false); I assume this is because the addEventListener and removeEventListener methods want a reference to the same function, while I've

List of an element's events

坚强是说给别人听的谎言 提交于 2019-12-03 14:18:39
Is there a way to find all of the events for a element in javascript? or a way to unbind all events from a element? Thanks. There is not way to do that directly using javascript. Jquery has a couple of functions to keep track of that data. One "pure" way to do that is to change the addEventListener/attachEvent function through prototyping (search about javascript prototype stuff, not the framework). Or if you have a custom function to hadle adding/removing events you can tune it. Well, that's it. Of course ! Take a look at this to bind/unbind events http://api.jquery.com/category/events/ and

Which hooks are provided in jQuery?

 ̄綄美尐妖づ 提交于 2019-12-03 13:36:40
问题 Officially only $.cssHooks is documented in jQuery API documentation, and $.valHooks is mentioned in a sentence for a workaround to a known issue in .val(). I wonder how many hooks are there in jQuery besides of these 2, and should we use $.valHooks in our plugin development? If so, I think it should be documented as a dedicated topic instead of one-sentence only. 回答1: There are 8 different types of exposed hooks. There is one more for internal usage only (which is exposed) - jQuery.

See all dom events for an element

此生再无相见时 提交于 2019-12-03 13:04:55
I have a jQuery UI datepicker that, when you click on a date, clears my URL hash to # , and doesn't change the date in the textbox. I assume there's some other JavaScript utility somewhere that has some sort of delegated event that's also being called, throwing an error, and killing the jquery handler. How can I step through, and or see all delegated events match this dom element . T.J. Crowder Chrome's dev tools can help with this: Point Chrome at the page Right-click the date in the jQuery UI datepicker and choose "inspect element". On the far right-hand side, there's an accordian with

Click through div with an alpha channel

倖福魔咒の 提交于 2019-12-03 12:53:59
I'm trying to replicate twitter's "fade out" layer at the bottom of the feed widget (on their main page at twitter.com). The only way I could come up with that didn't use html5 was place an absolute positioned div above the feed div, and give it an alpha channeled png with a white-to-transparent gradient above it. This was easy to achieve. Only problem now is that the divs that appear below the transparent layers are not clickable. Any idea about how to make the divs clickable? Maybe you have another method to replicate this effect altogether? Thanks! This article describes one method of

.onload called multiple times from Firefox extension

元气小坏坏 提交于 2019-12-03 12:40:31
问题 I'm developing a Firefox extension and have the following code: function initialize() { // For accessing browser window from sidebar code. var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIWebNavigation) .QueryInterface(Components.interfaces.nsIDocShellTreeItem) .rootTreeItem .QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIDOMWindow); var gBrowser = mainWindow.gBrowser;

Prototype - click event by element class name

不羁的心 提交于 2019-12-03 12:20:50
I am new to the prototype framework and am trying something really simple and failing. I am trying to respond to a click event on a button like so: $$('.btn').observe('click', respond); function respond(event) { alert("hello"); } Why isn't this working? Please help! Unlike jQuery, handing selectors with multiple results in Prototype works a little differently. You need to handle each selected result separately using .each() . $$('.btn').each(function(element) { element.observe('click', respond); }) This is one of the reasons I moved over to jQuery. The other reason: knowing jQuery is

Listen for keyboard events and mouse movement outside of Electron app

五迷三道 提交于 2019-12-03 11:30:45
I've been getting into a few Electron projects and I am trying to figure out how you could listen for any keypresses or and track mouse movement when the app is in the background. I am using the menubar plugin so the app is still running in the background. I tried using the global-shortcut API but it looks like that is for shortcuts only and you can't register individual keystrokes. I've also looked over the API and have yet to find an event for keystrokes and mouse movements outside the app's main screen. justin.m.chase This is outside of the realm of normal use-cases for an electron

How can I monitor scroll position while scrolling in Safari on iOS?

半世苍凉 提交于 2019-12-03 10:47:30
问题 I currently use $(window).bind('scroll', foo); to monitor $(window).scrollTop() and do stuff to create a parallax effect. In all desktop browsers foo() is called for each pixel the user scrolls, and everything is nice and dandy. In Safari on iOS, the scroll event is only fired AFTER the scrolling is finished. I added $(window).bind('touchmove', foo); to make sure the function is called during the swipe in iOS, and it got me a little bit further. When user releases finger, the page continues

JavaScript inside an <img title=“<a href='#' onClick='alert('Hello World!')>The Link</a>” /> possible?

安稳与你 提交于 2019-12-03 10:27:16
<img title="<a href='#' onClick='alert('Hello World!')>The Link</a>" /> So I've got some specific question.. I already know that I can work with attributes inside a TITLE attribute.. But can I work with events inside a TITLE attribute? (btw - It seems like a rubbish code, but this already works as is should on my web project - I just need a way to use some Javascript on this sheathed link.) I USE Jquery framework. No, this is, as you say "rubbish code". If it works as should, it is because browsers try to "read the writer's mind" - in other words, they have algorithms to try to make sense of