I have a page where some event listeners are attached to input boxes and select boxes. Is there a way to find out which event listeners are observing a particular DOM node and for what event?
Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Sunday, June 10, 2012
How to find event listeners on a DOM node?
Tuesday, June 5, 2012
Best book to learn web development for a professional developer?
I'm a professional software developer. I've been programming in a lot of different languages over the course of more than two decades now. Picking up a new programming language is very easy for me.
Friday, June 1, 2012
Rotating a Div Element in jQuery
Trying to rotate a div element...This might be DOM blasphemy, could it work possibly with a canvas element? I'm not sure - if anybody has any ideas of how this could work or why it doesn't, I'd love to know. Thanks.
Wednesday, May 30, 2012
Why don"t self-closing script tags work?
What is the reason browsers do not correctly recognize:
<script src="foobar.js" /> // self-closing script tag
Tuesday, May 29, 2012
How to debug Javascript/jQuery event bindings with FireBug (or similar tool)
I need to debug a web application that uses jQuery to do some fairly complex and messy DOM manipulation. At one point, some of the events that were bound to particular elements, are not fired and simply stop working.
Sunday, May 13, 2012
How to check if a css rule exists
I need to check if a css rule exists because I want to issue some warnings if a css file is not included.
Thursday, May 10, 2012
What"s the better practice: eval or append script?
I need to execute a custom piece of JavaScript I got from some AJAX call. I could do an eval
of the string or I could just append it in a script
-tag to the DOM. Which method would be better?
How to emulate Event.timeStamp
The timeStamp attribute must return the value it was initialized to. When an event is created the attribute must be initialized to the number of milliseconds that has passed since 00:00:00 UTC on 1 January 1970.
Wednesday, May 9, 2012
How to show a spinner while loading an image via JavaScript
I'm currently working on a web application which has a page which displays a single chart (a .png image). On another part of this page there are a set of links which, when clicked, the entire page reloads and looks exactly the same as before except for the chart in the middle of the page.
Monday, May 7, 2012
HTML/XML Parser for Java
What HTML parsers have the following features:
- Fast
- Thread-safe
- Reliable and bug-free
- Parses HTML and XML
- Handles erroneous HTML
- Has a DOM implementation
- Supports HTML4, JavaScript, and CSS tags
- Relatively simple, object-oriented API
Thursday, May 3, 2012
Detect if a jQuery object is on the page or not
Given a jQuery object, $j
, I need to know if it represents something that is already on the page or if it is something that has not yet been put on the page. For example, if I have this:
Tuesday, May 1, 2012
In web browser, what"s the difference between onblur and onfocusout?
If it is the same, then why there are two of this kind of event.
Thursday, April 19, 2012
Javascript getElementById lookups - hash map or recursive tree traversal?
Does the DOM have a hash-table of elements whose keys are the elements' ids?
Tuesday, April 17, 2012
Screen Coordinates of a element, via Javascript
I'm trying to get the screen coordinates (that is, relative to the top left corner of the screen) of an element in a browser window. It's easy to get the size and position of the window (screenX, screenY) and it's easy (with jQuery) to get the offset of the element ($('element').offset().left).
Thursday, April 12, 2012
jQuery: How to select "from here until the next H2”?
I'm setting up a very straightforward FAQ page with jQuery. Like so:
Sunday, April 8, 2012
jQuery leaks solved, but why?
I am working on a large enterprise application with a LOT of JavaScript. Enough that I can't possibly go through and fix all the small circular references that have been created over its past 5 years of development. While researching solutions I came across this small jQuery hack/patch:
http://kossovsky.net/index.php/2009/07/ie-memory-leak-jquery-garbage-collector/
and decided to try it. Amazingly, it works! sIEVE shows no leaks in the places I had previously identified them and the iexplore task is maintaining a more manageable memory footprint.
My question is, why does this work? jQuery.remove calls .removeChild, which should get rid of the element, but apparently does not. The patch instead appends the target element onto a new garbage collector div, which it then clears. Why does the patch method of removal completely free up the memory but jQuery's remove function does not? I'm hoping to understand why this works in order to possibly improve the solution before I check it in to the larger application.
Source: Tips4all
DOM Mutation event in JQuery or vanilla Javascript
Are there any DOM mutation events in JQuery or in vanilla Javascript that fire cross browser?
To clarify, say I have a script on my page which inserts a div into the body. I don't have access to the script and I don't know when the div has been inserted. I was wondering if there's a DOM mutation event that I can add a listener for to know when the div has been inserted. I know I can use some kind of timer to periodically check for the div but I don't really like the overhead that this would impose.
Source: Tips4all
How are JavaScript host objects implemented?
I was thinking about this today and I realized I don't have a clear picture here.
Here are some statements I think to be true (please correct me if I'm wrong):
- the DOM is a collection of interfaces specified by W3C.
- when parsing HTML source code, the browser creates a DOM tree which has nodes that implement DOM interfaces.
- the ECMAScript spec has no reference of browser host objects (DOM, BOM, HTML5 APIs etc.).
- how the DOM is actually implemented depends on browser internals and is probably different among most of them.
- modern JS interpreters use JIT to improve the code performance and translate it to bytecode
I am curious about what happens behind the scenes when I call document.getElementById('foo')
. Does the call get delegated to browser native code by the interpreter or does the browser have JS implementations of all host objects? Do you know about any optimizations they do in regard to this?
I read this overview of browser internals but it didn't mention anything about this. I will look through the Chrome and FF source when I have time, but I thought about asking here first. :)
Source: Tips4all
Friday, April 6, 2012
change html text from link with jquery
a simple question here
Is there a way to change the text "click here"
Pass mouse events through absolutely-positioned element
I'm attempting to capture mouse events on an element with another absolutely-positioned element on top of it. Right now, events on the absolutely-positioned element hit it and bubble up to its parent, but I want it to be "transparent" to these mouse events and forward them on to whatever is behind it. How should I implement this?