dom-events

Catch image dragged into a text field in Javascript

有些话、适合烂在心里 提交于 2019-12-12 16:04:26
问题 I want to allow a user to drag an image from a web page into my web app and then store and use the image url elsewhere in the application. So I'm creating an input field as the drag target. But since that allows to drop any draggable web object (like links), I need to do some error checking. I could put a button there, but it would be nicer if the drop is auto-detected. So the question is... are there any event handlers - primarily supported in IE7 and Firefox3 - that get triggered when the

keyDown event is not fired for Capslock in Mac

眉间皱痕 提交于 2019-12-12 13:41:44
问题 CHROME (52): When turning caps lock ON - only keydown is fired (no event in keyUp or keyPress) When turning caps lock OFF - only keyup is fired (no event in keyDown or keyPress) FIREFOX (46): Only keyDown event is fired for both caps lock ON & OFF (no keyUp or keyPress) I've read about the keyCodes and events here http://www.quirksmode.org/js/keys.html and in MDN here https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode, aaaand here http://unixpapa.com/js/key.html But none

Simulate Enter In JavaScript

自古美人都是妖i 提交于 2019-12-12 10:46:00
问题 I try to simulate Enter in JavaScript in a specific TextArea . This is my code: function enter1() { var keyboardEvent = document.createEvent('KeyboardEvent'); var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? 'initKeyboardEvent' : 'initKeyEvent'; keyboardEvent[initMethod]('keydown', // event type : keydown, keyup, keypress true, // bubbles true, // cancelable window, // viewArg: should be window false, // ctrlKeyArg false, // altKeyArg false, // shiftKeyArg false, //

How to set value on click of link in vaadin

爷,独闯天下 提交于 2019-12-12 10:17:09
问题 I am new to vaadin. I have one Link like Link link = new Link("", new ExternalResource(redirectURL)); my requirement is, I have to set value when user clicks the link. Can I add listener when user click the link. Or is there alternate ways of setting value if link is clicked. 回答1: To capture onClick on a link or a label, I always create a HorizontalLayout and put the component inside it: HorizontalLayout hor = new HorizontalLayout(); final Link link = new Link("Click on Me!", new

Javascript Scroll Handler not firing

痞子三分冷 提交于 2019-12-12 09:31:25
问题 All I'm trying to do is to call a function when a DIV is scrolled.For simplicity sake Im not specifying anything else. Also I am only looking at DOM compliant browsers like Chrome, Safari (not IE). MY problem is that the scroll handler never gets called. If I replace the scroll to click , it works when I click. Somehow the scroll is not working. Please note: I cannot use jQuery :( Here is my code: HTML: <div id="test">--long content--</div> JS: function myFunc() { console.log('in myFunc'); }

Detect changes on the url

落爺英雄遲暮 提交于 2019-12-12 08:49:11
问题 I need something to detect changes on the url but the page doesn't do post back, it changes dynamically adding just the div inside the html, so the URL page is something like this http://www.examplepage/conversations/44455 and when I click on another section of the page it it is http://www.examplepage/conversations/44874 it changes not only at the end but like this http://www.examplepage/settings without doing post back and reloading the javascript so my question is, is there a way to detect

Cross Browser Event object normalization?

一个人想着一个人 提交于 2019-12-12 08:48:53
问题 I'm looking for a good resource on event normalization on the event object. I'm trying to do it myself but I keep feeling like I'm going to miss something. Here's what I have so far, tell me if I missed anything. var eFix = function(e) { e = e || window.event; e.target = e.target || e.srcElement; e.offsetX = e.offsetX || e.layerX; e.offsetY = e.offsetY || e.layerY; e.relatedTarget = e.relatedTarget || e.type == 'mouseover' ? e.fromElement : e.toElement; e.target = e.target || e.srcElement; if

Files input change event fires only once

試著忘記壹切 提交于 2019-12-12 08:27:16
问题 I've made a small script using some of the HTML5 files features, which allows you to select one or more files, and each time it will write the name of the file(s). Everything works as it should, only the event to detect the value change of the files input fire only once, so how can I make it fire every change and not only on the first change? By the way, here is what I made: http://tamir.netspot.co.il/html5/files/ 回答1: It appears that the change event listener is being removed because you're

How to list all registered events of a DOM node using Javascript?

房东的猫 提交于 2019-12-12 08:26:50
问题 I can add or remove an event handler for a DOM node. Is it possible to find out all the registered events handlers of a given DOM node? I am referring to straight Javascript meaning no frameworks or toolkits like jQuery, dojo, Prototype, GWT, etc. If the answer is no, any reason why? Security issues? 回答1: I know this is an old question, but just in case, for chrome you can use getEventListeners https://developers.google.com/chrome-developer-tools/docs/commandline-api#geteventlistenersobject

Click through div with an alpha channel

假如想象 提交于 2019-12-12 07:54:47
问题 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