dom-events

Capture “done” button click in iphone's virtual keyboard with Javascript

元气小坏坏 提交于 2019-11-28 06:45:43
I'm wondering if there's a way to capture the iPhone's virtual keyboard's done button event, using JavaScript? Basically, I just want to be able to call a JS function when the user clicks done. The done key is the same as the enter key. So you can listen to a keypress event. I'm writing this using jQuery and i use it in coffee script so I'm trying to convert it back to js in my head. Sorry if there is an error. $('someElem').bind("keypress", function(e){ // enter key code is 13 if(e.which === 13){ console.log("user pressed done"); } }) I was unable to track the 'done' button being clicked. It

JavaScript Event Listeners vs Event Handlers

风格不统一 提交于 2019-11-28 06:32:57
Ok, I have been trying to figure this out for a long time now and finally have the time to investigate. As the title suggests "What is the difference"? I know that this works the way I want it to. addLoadEvent(converter); // Converter function converter() { var pixels = document.getElementById("pixels"); pixels.addEventListener("keyup", updateNode, true); pixels.addEventListener("keydown", updateNode, true); } But this doesn't, and only runs once. addLoadEvent(converter); // Converter function converter() { var pixels = document.getElementById("pixels"); pixels.onkeydown = updateNode; pixels

How do you Hover in ReactJS? - onMouseLeave not registered during fast hover over

会有一股神秘感。 提交于 2019-11-28 04:48:39
How can you achieve either a hover event or active event in ReactJS when you do inline styling? I've found that the onMouseEnter, onMouseLeave approach is buggy, so hoping there is another way to do it. Specifically, if you mouse over a component very quickly, only the onMouseEnter event is registered. The onMouseLeave never fires, and thus can't update state... leaving the component to appear as if it still is being hovered over. I've noticed the same thing if you try and mimic the ":active" css pseudo-class. If you click really fast, only the onMouseDown event will register. The onMouseUp

Detecting onChange events from a CKEditor using Jquery

喜你入骨 提交于 2019-11-28 04:29:48
I'm working with the CKEditor and jQuery and I'd like to toggle a flag to true whenever a user changes the value of a field. One of those fields is a CKEditor instance. All the textareas that have the "wysiwyg" class get converted to CKEditors but somehow the $('.wysiwyg').change() event never gets detected. I did some googling but the keyword combination seems to bring up nothing but irrelevant results (my google-fu sucks). Thanks for any help :) Edit: for (var i in CKEDITOR.instances) { CKEDITOR.instances[i].on('click', function() {alert('test 1 2 3')}); } I tried the code above and it doesn

How to know when Google search results page renders its results?

痞子三分冷 提交于 2019-11-28 02:11:42
问题 I'm writing a Chrome extension that injects scripts to the Google's search result page and modified all the results' anchor elements. My problem is that the results are rendered asynchronously and are not shown in the page on document load/ready. I had 2 initial solutions which don't work: Set a timeout: Bad practice but it works. Nevertheless, might show inconsistent results so I prefer to avoid this solution. Bind to 'DOMNodeInserted'. Generally works, but more complicated in my case

Remove keydown delay in JavaScript?

拜拜、爱过 提交于 2019-11-28 01:27:12
问题 Well, when you hold a key on your keyboard, after the first fire there is a 1sec delay. You can go ahead and open notepad and hold a key (e.x 'x') you'll see after the first fire there is a delay. However, I'm trying to develop a game in HTML5 Canvas with JavaScript, and that 1sec delay is very annoying, Additionally, it stops the player walking animation.. So how can I delete that annoying delay in JavaScript ( no jQuery! ) ? My keydown event works in this pattern - document.onkeydown =

How can I check if url of current browser tab is changed?

人盡茶涼 提交于 2019-11-27 22:43:48
问题 I need it to use in my Firefox extension. I already tried window.onload event listener, and check if current url == old url, and it's a good idea, but it doesn't work when page loads PDF. I saw hash changed function too but it works only with Firefox 3.6; I need it to work at least with Firefox 3. So, I need an event listener that check if document.location changes. 回答1: For example, you could use: var mainWindow = window .QueryInterface(Components.interfaces.nsIInterfaceRequestor)

How to detect class changing by DOMAttrModified

感情迁移 提交于 2019-11-27 22:33:39
I need to detect some class changing, i use for this DOMAttrModified, but something is wrong, what? var first_img = $('body').find('li:first').find('img'); first_img.on('DOMAttrModified',function(e){ if (e.attrName === 'class') { if ($(this).hasClass('current-image')) { $(this).removeClass().addClass('previous-image'); } console.log('log'); } }); Thx for advice. The immediate problem is that a attrName property isn't part of jQuery's event's object...you need to use e.originalEvent.attrName . Here's an example of it working: var first_img = $("body").find("div").first(); first_img.on(

Is there a way in JavaScript to listen console events?

青春壹個敷衍的年華 提交于 2019-11-27 20:12:34
I'm trying to write handler for uncaught exceptions and browser warnings in Javascript. All errors and warnings should be sent to server for later review. Handled exceptions can be caught and easily logged with console.error("Error: ..."); or console.warn("Warning: ..."); So they are not problem if they are called from javascript code, even more, unhandled exceptions could be caught with this peace of code: window.onerror = function(){ // add to errors Stack trace etc. }); } so exceptions are pretty covered but I've stuck with warnings which browser sends to console. For instance security or

Google Maps Drawing Manager limit to 1 polygon

半城伤御伤魂 提交于 2019-11-27 19:31:35
I am creating a map with the google maps v3 API. Using the drawing manager to draw shapes. Is there a way to disable the polygon button after 1 polygon has been drawn? I been reading thru the API but can't find any events for polygon start, only for polygoncomplete. Maybe a way to detect drawingmode change? or remove google.maps.drawing.OverlayType.POLYGON but put it back if the current polygon was deleted? documentation . Start from this sample . hide the drawing control in the polygoncomplete event drawingManager.setOptions({ drawingControl: false }); add the drawing control in the