dom-events

iOS 6 safari, setInterval doesn't get fired

余生颓废 提交于 2019-11-29 10:28:26
问题 It seems if I'm scrolling the window , the window.setInterval doesn't get attached / fired while the scrolling is happening or after. Has anyone else seen the same issue? I mean... What could be causeing this? What can I do to fix this? 回答1: iOS halts almost everything in response to user touch to guarantee it feels responsive. The setInterval issue is known, and there doesn't appear to be a workaround. setInterval pauses in iphone/ipad (mobile Safari) during scrolling EDIT During the "freeze

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

柔情痞子 提交于 2019-11-29 08:55:52
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 because I insert new nodes my self before the anchors, which triggers a recursion. I can insert code to avoid

How to generate a right-click event in all browsers

谁都会走 提交于 2019-11-29 08:05:25
A little context: The app I'm working on has a right-click context menu for certain objects on the screen. The current design as that each of these objects listens for a right-click, sends an AJAX request to get the context data for that object, uses that data to create a PopupMenu2 from Dojo 0.4.3 (I know!), and then generates a right-click to launch the Dojo menu. I'm trying to figure out a way to generate a right-click event for all browsers. Currently, we only support IE and use the oncontextmenu event. Restrictions: No jQuery :( I cannot pre-load all the data for the objects on screen to

Microsoft Surface: How do I allow JavaScript touch/drag events to work without being intercepted by the browser?

天大地大妈咪最大 提交于 2019-11-29 04:42:31
I have a Google Maps map on my web site, but when using it with a Microsoft Surface tablet, the "pan" gesture is intercepted by the browser -- it tries to go to the next browser window. How do I allow the pan (drag event) to be ignored by the browser so the map behaves normally? Going to maps.google.com , the map is perfectly dragable, so there must be a workaround that Google employs. JoeDuncan According to MS's guide on "Pointer and gesture events" (here: http://msdn.microsoft.com/en-us/library/ie/hh673557%28v=vs.85%29.aspx#Panning_and_zooming ) you need to add a CSS class to the element you

trigger custom event without jQuery

独自空忆成欢 提交于 2019-11-29 03:22:17
I'm triggering some DOM Events with jQuery triggerHandler() <!DOCTYPE html> <html> <head> <title>stackoverflow</title> <script src="http://ajax.googleapis.com:80/ajax/libs/jquery/2.1.3/jquery.min.js"></script> </head> <body> <script> $(document).ready(function() { $(document).on('hey', function(customEvent, originalEvent, data) { console.log(customEvent.type + ' ' + data.user); // hey stackoverflow }); // how to this in vanilla js $(document).triggerHandler('hey', [{}, { 'user': 'stackoverflow' }]) }); </script> </body> </html> How can I trigger this without jQuery? Important : I need to know

Can I change the context of javascript “this”?

删除回忆录丶 提交于 2019-11-29 02:56:43
var UI$Contract$ddlForm_change = function() { //'this' is currently the drop down that fires the event // My question is can I change the context so "this" represents another object? this = SomeObject; // then call methods on the new "this" this.someMethod(someParam); }; is this possible? James No, it's not possible. You can call a method with a specified value for this (using method.apply() / method.call() ) but you cannot re-assign the keyword, this . You can't change what this refers to from inside the function. However, you can call a function in a specific context - so that this refers to

Firing and capturing custom events

与世无争的帅哥 提交于 2019-11-29 02:39:23
问题 Imagine this scenario (it's really just a scenario): I have a global counter that gets incremented on every mouse click. when I reach 50 clicks, I want to fire a custom event named 'reachedCount' I want to register my window object to capture that event with something like window.addEventListener('reachedCount', function(args){alert(args.count);}, false) So, my problems are that I don't know, and can't find anywhere how I can pass arguments to my eventHandler. Also, I had tried the method

Netflix video player in Chrome - how to seek?

我是研究僧i 提交于 2019-11-29 02:24:42
I have been unable to figure out how to do a video seek (automatically advance to a certain point in the video) in the Netflix video player running in Chrome. The currentTime property can be read but not set in the Netflix player, and when set, immediately triggers the error "Whoops! Something went wrong.". Other actions such as Play and Pause work quite well. For example, you can try the following: Log into Netflix (from Google Chrome) and go to the movie Armageddon . After the movie loads, pause it if it starts playing. Open the Chrome Developer Tools panel. Go to the Console tab. Paste the

The Order of Multiple Event Listeners

做~自己de王妃 提交于 2019-11-28 22:02:57
I've come across an oddity while using Prototype to handle click events. If you click the button in the code below, it will trigger three alerts: 'Click 1', 'Click 2' and 'Click 3'. Modern browsers will invoke the listeners in the order they are registered in, while IE8 (and perhaps older IE versions as well) will invoke them in the opposite order. I find this odd because I thought Prototype maintained and executed a queue of listeners, which should be browser independent. Is this not so? If not, are event listeners supposed to be run in a certain order or are they asynchronous and thus their

Proper technique to add listeners to DOM created via an XTemplate?

怎甘沉沦 提交于 2019-11-28 20:35:19
问题 We use XTemplates - lots of XTemplates. They are great for displaying read-only content. But have you ever added (Ext JS) listeners to DOM created via a template? Would you care to share your preferred technique for creating these listeners? 回答1: My preferred technique is using the analog of $.live function from jquery. F.i. let's assume you are going to use xtemplate for creating simple list like the following: <ul class="nav"> <li><a href="example.com">item1</a></li> <!-- ... --> </ul> To