dom-events

Can't add listener to a SVG in Internet Explorer using SVGweb

吃可爱长大的小学妹 提交于 2019-12-10 15:42:03
问题 This code works great in Firefox, but not in IE. I've read the documentation of SVGWeb (http://svgweb.googlecode.com/svn/trunk/docs/UserManual.html), but I don't find/understand the solution, any idea? window.onsvgload = function() { carga(); var mySVG = document.getElementById("mySVGObject").contentDocument; mySVG.addEventListener('click', function(evt) { alert(evt.target.id); }, false); } I'm using things like this in IE without problems: mySVG.getElementById('Color2').style.fill='#00cc00'

d3.event is null inside of debounced function

不打扰是莪最后的温柔 提交于 2019-12-10 13:33:49
问题 When attempting to use a debounced version of a mousemove event handler, d3.event is null . I'd like to use the d3.mouse object in this de-bounced handler, but d3.event returns null and throws an error. How can I have access to d3.event in the following code: // a simple debounce function function debounce(func, wait, immediate) { var timeout; return function() { var context = this, args = arguments; var later = function() { timeout = null; if (!immediate) { func.apply(context, args); } };

Javascript onClick function for google's GeoChart

我是研究僧i 提交于 2019-12-10 12:55:14
问题 I am trying to display a map using google's geochart https://developers.google.com/chart/interactive/docs/gallery/geochart The map displays the data and specified countries fine, but I can't work out how assign a link onClick to each specific country, or even get any onClick function for the countries. This link describes the Events 'regionClick' and 'select', which sounds like part of what I need, though I'm not sure how these will trigger my link function...Im new to javascript. With

Disable Right Click Context Menu? [duplicate]

孤街浪徒 提交于 2019-12-10 12:16:25
问题 This question already has answers here : How do I disable right click on my web page? (23 answers) Closed 4 years ago . This tool increments the value at strength on left click at the value of strength and decrements the value on left click. This works, however the context menu appears when you do a right click to decrement the value. How can I get rid of it? CODE AND DEMO var Alexander = { Strength: "AlexanderStrengthVal", Bonus: "AlexanderRemainingBonusVal", Limits: { Strength: 60, } };

Trigger change event for React rendered input (type=range)

时间秒杀一切 提交于 2019-12-10 11:58:34
问题 "react": "^15.4.2" I am having trouble triggering the change event from jquery for an input rendered with React. I need to do this for some end to end testing. here's a sandbox as a full showcase: https://codesandbox.io/s/pp1k1kq3om with jquery already loaded. If you run : $('#reactSlider').val(50).change() in the console, you'll notice that the change handler isn't called. In the sandbox above there's also a pure html slider for comparison, that one works as expected (change function is

Remove event listener with d3js not working

余生长醉 提交于 2019-12-10 11:09:27
问题 I have an SVG structure where there are some shapes inside. I want to fire an event when a shape is clicked and another one when is clicked over the SVG. The problem is the SVG event is always fired. In order to prevent this I'm disabling event bubbling from the shape. Also I've tried to disable the event with d3 but seems to not work. Also tried to disable event with the native Javascript code. An example of the super simple code is: SVG structure <svg id="canvas" xmlns="http://www.w3.org

React, ineffiencies of binding a new function for each event

限于喜欢 提交于 2019-12-10 11:05:57
问题 My friend and I are having an argument. In the interest of full disclosure, I'm the one who's a big fan of React and its benefits. In React components, when attaching a DOM event to each element in a list of elements, the traditional pattern is to bind() the generic click handler with the values you want to pass along to that function as parameters. As written below: <button onClick={this.onButtonClick.bind(this, buttonIndex)}></button> where buttonIndex is some value that changes as the list

Simple event system using JavaScript (ES5) - JS Custom Event

最后都变了- 提交于 2019-12-10 10:45:49
问题 Instructions: make this code work without modifying snippet it in any way. Use only plain old JavaScript and no third-party libraries. Write new code that enables the code below to work properly. Hint: Feel free to extend native objects... even though it's typically a bad practice. // Start with an object, any object var myObject = {}; // Register an event on your object using // an `on` method myObject.on('myEvent', function(data) { // Log the data passed to the callback console.log(data); }

JavaScript EventListener “pointerMove”: points per second

不问归期 提交于 2019-12-10 10:39:01
问题 I have an element with a "pointerMove" EventListener added to it. Now when moving my mouse around, I can measure the number of data points "pointerMove" delivers per second (pps) by counting the total number of points drawn since "pointerDown" and dividing this by the time that passed since "pointerDown". So far, so good. What is strange though is the fact that I get a higher pps rate when the developer console is opened. Example: Pressing my mouse button and then moving the cursor around

Using clearTimeout to cancel a timeout event

喜夏-厌秋 提交于 2019-12-10 04:34:19
问题 I have the following code but the clear timeout doesn't work and I can't understand why, does anyone have any ideas? (Using the Prototype framework) function foo() { $("navigation").observe('mouseover', function (event) { clearTimeout(bar); } ).observe('mouseout', function (event) { setTimeout(bar, 1000); } ); } function bar() { alert("hi"); } 回答1: You need to store the result of setTimeout in a variable, and use clearTimeout to clear that variable, not the function: var timer; function foo()