javascript-events

React Synthetic Event distinguish Left and Right click events

早过忘川 提交于 2020-01-21 00:46:13
问题 I am trying to distinguish between left and right clicks in an OnClick function. But, var r = React.createClass({ handleClick : function(e){ //left click if(e.which==1){ //Do something } }, render : function(){ return <p onClick={this.handleClick}>Something </p> } }); Turns out e.which is undefined for Synthetic Events. How can I distinguish between left and right clicks here? 回答1: You can do something like this too. Have both onClick and onContextMenu handlers return <p onClick={this

Capture a div as an image [duplicate]

烈酒焚心 提交于 2020-01-20 08:27:38
问题 This question already has answers here : user capture div as image and save to computer (4 answers) Closed 2 years ago . I have some div tags containing charts rendered by javascript. I want to export them in an image format by the press of a button. I don't know if it's possible to capture a div tag as an image using javascript ! so there i'm asking for tips and hints. Thanks in advance. 回答1: You can create an image using the canvas element. If your charts are rendered using HTML elements

Capture a div as an image [duplicate]

淺唱寂寞╮ 提交于 2020-01-20 08:27:18
问题 This question already has answers here : user capture div as image and save to computer (4 answers) Closed 2 years ago . I have some div tags containing charts rendered by javascript. I want to export them in an image format by the press of a button. I don't know if it's possible to capture a div tag as an image using javascript ! so there i'm asking for tips and hints. Thanks in advance. 回答1: You can create an image using the canvas element. If your charts are rendered using HTML elements

How can I pass events on to a hidden <browser>?

試著忘記壹切 提交于 2020-01-17 12:52:28
问题 I've working on a simple view around a browser using XULRunner 1.9.2. <?xml version="1.0"?> <?xml-stylesheet type="text/css" href="chrome://global/skin/"?> <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"> <hbox equalsize="always" flex="2"> <browser flex="1" type="content-primary"/> <html:canvas flex="1"/> </hbox> </window> I've written some Javascript that handles MozAfterPaint events from the <browser> , pushes them to

How can I pass events on to a hidden <browser>?

不问归期 提交于 2020-01-17 12:52:24
问题 I've working on a simple view around a browser using XULRunner 1.9.2. <?xml version="1.0"?> <?xml-stylesheet type="text/css" href="chrome://global/skin/"?> <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"> <hbox equalsize="always" flex="2"> <browser flex="1" type="content-primary"/> <html:canvas flex="1"/> </hbox> </window> I've written some Javascript that handles MozAfterPaint events from the <browser> , pushes them to

Make onKeyDown trigger an HTML button's onClick event

你。 提交于 2020-01-17 07:08:30
问题 I have a basic HTML form named Calculator, with a button named "btnOne". What I want is for when the user presses the "1" key on the keyboard, the "btnOne" HTML button's onClick event to occur. To attempt to accomplish this, I placed this function in the Head tag of my document: <head> <SCRIPT LANGUAGE="JavaScript"> //other functions... document.onkeydown = function(e){ if (!e) e = window.event; if(e.keycode == '49') { document.Calculator.btnOne.click(); } return false; } </SCRIPT> </head> Am

CTRL keyCode (17) not working in JavaScript?

怎甘沉沦 提交于 2020-01-17 05:32:13
问题 I have the following code which adds an eventListener to a HTML textarea. It's supposed to console log the keycode which was pressed, and, if the keyCode is == to 17 (CTRL), console log "You pressed CTRL.". For some reason, when I press CTRL in the textarea, it's not console logging the keyCode which was pressed, nor "You pressed CTRL." If I press "A" for example, console log return "97" which is correct. It also works with all other letters. Here's the code: document.getElementById("msgBox")

why it is bad practice to register events to document in jquery?

為{幸葍}努か 提交于 2020-01-16 03:52:13
问题 Whenever I read about event registration in jquery they all say that we should try to add event handlers to the nearest parent, and avoid adding event listeners to the document, because according to resources they are slow and not efficient. But why they are slow? Apparently it's because the event will have to bubble up to the document, which will take time. Then it will be compared to a list of selectors to call, e.g. $(document).on("click", ".abc", function(){ }) $(document).on("click", "

How to prevent jquery datepicker from popping up on initial page load but still scroll to datepicker textbox

房东的猫 提交于 2020-01-16 01:20:16
问题 I have something similar to the following javascript: $(function () { $("#txtDate").focus(); $("#txtDate").datepicker({ ... autoOpen: false, ... }); }); I want to focus in on the textbox on page load without having the datepicker pop up. Currently the page loads with the datepicker already open. I need to be able to have the page scroll to that textbox on page load and it would be nice for the txtDate textbox to have focus so that users can tab to the next input in the form easily. Any help

JavaScript force an OnChange in Maximo

天大地大妈咪最大 提交于 2020-01-15 23:02:20
问题 I'm currently working on a Bookmarklet for Maximo, which is a Java EE application, and I need to populate a few input boxes. Generally when a use inputs data into the box they click a button that gives them a popup and they search for the value to be added to the script. Or they can type the name and hit tab/enter and it turns it to capital letters and does a few things in the background (not sure what it does exactly). I currently use Javascript: $('mx1354').value = "KHBRARR"; $('mx1354').ov