dom-events

When should I observe Javascript events on window vs. document vs. document.body?

前提是你 提交于 2019-12-03 04:35:56
I'm using prototype.js for my web app, and I have everything running on Chrome, Safari, and Firefox. I am now working on IE8 compatibility. As I've been debugging in IE, I've noticed that there are Javascript events for which I have previously set an observer on the window, e.g. Event.observe(window, eventType, function () {...}); (where eventType might be "dom:loaded" , "keypress" , etc.) and it works just fine in Chrome/Safari/Firefox. However, in IE the observer never fires. In at least some cases I could get this to work on IE by instead placing the observer on something other than window

Event vs CustomEvent

巧了我就是萌 提交于 2019-12-03 04:14:59
问题 I was wondering, what is the purpose of CustomEvent , because it can be easily emulated by good old Event . So, what is the difference between: var e = new Event("reload"); e.detail = { username: "name" }; element.dispatchEvent(e); and var e = new CustomEvent("reload", { detail: { username: "name" } }); inner.dispatchEvent(e); Why does CustomEvent exist if it is easy to attach custom data to ordinary Event object? 回答1: It's not the same. You can't set the detail of a real CustomEvent: var

Google Maps API v3: Is there a callback or event listener for a setMap() event?

て烟熏妆下的殇ゞ 提交于 2019-12-03 03:56:21
问题 I am using Google Maps API v3 on a website I am developing. I have a drop-down box beneath my map which allows the user to switch between different sets of markers to be displayed on the map. Each marker is displayed using marker.setMap() . My problem is that the map sometimes takes a long time to display the new markers, especially in IE. I want to show a "Loading" animation while the map is switching markers. But I don't know how to detect when the map has finished displaying the new data

Select All checkbox by Javascript or console

一笑奈何 提交于 2019-12-03 03:47:08
问题 I am having 100 Checkboxes on my web page. For testing purposes I want to tick all those boxes, but manually clicking is time consuming. Is there a possible way to get them ticked? Perhaps a JavaScript or Chrome Console window, anything? 回答1: The most direct way would be to grab all your inputs, filter just the checkboxes out, and set the checked property. var allInputs = document.getElementsByTagName("input"); for (var i = 0, max = allInputs.length; i < max; i++){ if (allInputs[i].type ===

Are there significant differences between the Chrome browser event loop versus the node event loop?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 03:45:09
问题 Philip Roberts does a brilliant job explaining the browser event loop here providing a clear explanation between the call stack, event loop, task queue, and then "outside" threads like webapis. My question is do these parallel the equivalent components in the Node event loop and are they called basically the same thing. That is, when I make a call using Node's file and web i/o libraries, these are things that happen outside the stack whose callbacks are queued in a task queue? 回答1: ...when I

.onload called multiple times from Firefox extension

和自甴很熟 提交于 2019-12-03 02:57:55
I'm developing a Firefox extension and have the following code: function initialize() { // For accessing browser window from sidebar code. var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIWebNavigation) .QueryInterface(Components.interfaces.nsIDocShellTreeItem) .rootTreeItem .QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIDOMWindow); var gBrowser = mainWindow.gBrowser; gBrowser.onload = function() { alert('loaded'); }; } When I open the extension (a sidebar) and proceed

Which hooks are provided in jQuery?

假如想象 提交于 2019-12-03 02:57:50
Officially only $.cssHooks is documented in jQuery API documentation , and $.valHooks is mentioned in a sentence for a workaround to a known issue in .val() . I wonder how many hooks are there in jQuery besides of these 2, and should we use $.valHooks in our plugin development? If so, I think it should be documented as a dedicated topic instead of one-sentence only. There are 8 different types of exposed hooks. There is one more for internal usage only (which is exposed) - jQuery._queueHooks() . There are also two other hooks: nodeHook and boolHook which are used internally and their

How to trigger checkbox click event even if it's checked through Javascript code?

六眼飞鱼酱① 提交于 2019-12-03 02:34:38
问题 I have many checkboxes in my page and there is a select all checkbox which checks all the checkboxes. Somehow I want to emulate that click event of checkbox even if it's checked/unchecked through select all button. How can I do it? 回答1: You can use the jQuery .trigger() method. See http://api.jquery.com/trigger/ E.g.: $('#foo').trigger('click'); 回答2: Getting check status var checked = $("#selectall").is(":checked"); Then for setting $("input:checkbox").attr("checked",checked); 回答3: You can

ExtJS Infinite Scroll Grid with remote Filters and Sort

牧云@^-^@ 提交于 2019-12-03 02:27:02
问题 In ExtJS 4.1 beta 2 I managed to implement an infinite scroll grid with a remote store. I basically took an existing (fully operational) paging grid (with remote store, filtering and sorting) and then put in the appropriate configs for infinite scrolling: // Use a PagingGridScroller (this is interchangeable with a PagingToolbar) verticalScrollerType: 'paginggridscroller', // do not reset the scrollbar when the view refreshs invalidateScrollerOnRefresh: false, // infinite scrolling does not

What is the DOM and BOM in JavaScript?

独自空忆成欢 提交于 2019-12-03 01:34:00
问题 What is the DOM and BOM in JavaScript? If someone could explain these in layman terms it would be great! I like to get a deeper understanding of these. 回答1: The BOM (Browser Object Model) consists of the objects navigator , history , screen , location and document which are children of window . In the document node is the DOM (Document Object Model), the document object model, which represents the contents of the page. You can manipulate it using javascript. 回答2: DOM - Document Object Model