dom-events

Events attached to object inside canvas

人盡茶涼 提交于 2019-12-09 01:16:44
问题 I have simply canvas code which draw rect on the canvas var x=document.getElementById("canvas"); var ctx=x.getContext("2d"); ctx.rect(20,20,150,100); ctx.stroke(); is it possible to add eventListener on said rect? For example, if I click on rect, it will turn red. 回答1: Regions Depending on how well you want to support various and older browsers, there is addHitRegion() that you can use by enabling it through flags in Firefox and Chrome (at the moment of this being written): Firefox: about

Google Maps v3 InfoBox Event Propagation in Mobile Safari

♀尐吖头ヾ 提交于 2019-12-08 20:49:38
I have created an infobox using google maps api v3 and infoBox from the maps utility library . The infobox has overflow-y data. Scrolling works exactly as expected on IE, FF, Chrome and Safari desktop. Scrolling does not work at all, however, in mobile Safari. It's almost as if the infoBox doesn't detect a touch to start scrolling. I've created this jsfiddle to demonstrate the problem. As you can see (in the iOS simulator or on an iOS device), the mouseenter, touchstart, mouseleave and touchend events are being triggered just fine; it's just that there is no way to scroll down to see the

Invoke Javascript event on control from C# web browser control

若如初见. 提交于 2019-12-08 19:25:33
问题 I am working on a web scraper in C# where I have a web browser control that loads a web page, I then collect data and depending on the data also acting on it. My problem is that I need to write some data to a input (textbox) that has listeners. The input control never shows a value in the html, it is handled by some Javascript that is fired from events on the control. I can set a value to the controls value parameter but it is as it is missing when I click OK on the form. I have searched the

Storage event not firing

匆匆过客 提交于 2019-12-08 18:33:22
问题 Attaching the event: $(window).on("storage", function (e) { //callback not getting hit }); Trying to fire the event: localStorage.setItem("test", "123"); I have two tabs open, both listening to the storage event. I can see the localStorage getting updated correctly on both tabs. However when I change localStorage on one tab, the other never fires the event. Any ideas? Tried on Chrome/Firefox. Domain format is https://www.xxx.yyy.zzz . 回答1: StorageEvent is fired in different page with the same

Disable a link in IE9 - prototype stop() not working

£可爱£侵袭症+ 提交于 2019-12-08 16:03:04
问题 IE9 is still in Beta, but all the same, here is a question: Using prototype.js 1.6.1, proper form for adding a click event to a link, and override the default link behavior, would be: mylink.observe('click', function(e){ doSomething(); e.stop(); }); While this works perfectly in every other browser that I tried, IE9 is a unique case. The default event behavior fires and my link takes me to the linked location. It seems that stop() isn't doing its job in IE9. The following code works perfectly

How to clear an input value on some button press?

落花浮王杯 提交于 2019-12-08 14:35:15
问题 I'm trying to clear an input when a user presses comma ( , ). So what I did was, on (keypress) I would check the keyCode and if it's a comma I would clear the input by setting the input value to input.value = '' . HTML: <input type="text" #elem (keypress)="clearInput($event)"> Code: @ViewChild( 'elem' ) public element; clearInput( e: KeyboardEvent ) { if ( e.keyCode === 44 ) { this.element.nativeElement.value = ''; } else { console.log('Not a comma'); } } 回答1: Use Event.preventDefault(). Add

Using service to listen for DOM events in Angular

我的梦境 提交于 2019-12-08 13:55:58
问题 I have a generic pop-up component in my Angular 4 application and in order to correctly handle popup display I need to listen for global click events on the document . There could be many pop-up components at the same time in the application and I need to close them when user clicks somewhere outside of the those components. I shouldn't bind to document:click event from the component itself for obvious reasons (there should be only one listener), so I've decided to create a centralized

Fade In circles in Google Maps

南楼画角 提交于 2019-12-08 09:50:33
On my map, I have it so that a node/circle is drawn at a certain location, and when this node is clicked, other related nodes appear nearby. However, I'd like to have them fade in after about one second instead of just appearing suddenly. I already had a look at this solution, but I couldn't really understand how it would translate over to my code. Is there an easy way to do this? ... function initialize() { for(var num = 0; num < lat.length; num++) { nodeInfo[num] = { center: new google.maps.LatLng(lat[num], lon[num]) } } // Styles var styles = [ { stylers: [ { hue: "#2222EE" }, { saturation:

Javascript: how to overwrite page reload event?

≡放荡痞女 提交于 2019-12-08 09:41:37
问题 What I mean is - when user clicks on some browser page reload/refresh button we do not want to reload page - we want to capture that event and call some function (for simple example one with some alert). I need it to work in IE6 and up and Chrome and Firefox3+ of course. How to do such thing (not using jQuery and other libs)? 回答1: You cannot. You can't change the operating system functionality from within any browser except IE. 回答2: It's not possible. You can detect when an unload occurs, but

onchange event in JavaScript - dependent option list

China☆狼群 提交于 2019-12-08 09:01:44
问题 I am trying to automate some task in IE with information from an Excel file. My knowledge in VBA lets me get to a point where I answer to a question in the website with "yes" and that should open another question with more options to select. As said I get to the first yes but then the other question doesn't appear. Here is part of the JavaScript code from the website and part of the HTML code: var elemData = jQuery.data( elem ); // If no elemData is found then we must be trying to bind to one