Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Webpage Element Information

by erroneousBollock (Curate)
on Nov 15, 2007 at 04:37 UTC ( #650915=note: print w/replies, xml ) Need Help??


in reply to Re: Webpage Element Information
in thread Webpage Element Information

Second, clicks propagate to parents. If you click on a link it will also receive the click for the paragraph the link is in, the div the paragraph is in, the body the div is in, and the html the body is in. I don't know how to solve that but the jQuery list is very friendly, I'm sure someone does.
The event will only have a single target attribute, so you can always test for equality in the handler. When you do handle the event at the target node, you can stop propagation of the event like so:

[event].cancelBubble = true; if ([event].stopPropagation) [event].stopPropagation();

-David

Replies are listed 'Best First'.
Re^3: Webpage Element Information
by Your Mother (Bishop) on Nov 15, 2007 at 21:04 UTC

    That's great and works on Safari and FF at least. Amended jQuery block.

    // <![CDATA[ $(document).ready(function() { $("*").bind("click", function(evt){ var info = $(this).position(); info["height"] = $(this).height(); info["width"] = $(this).width(); info["lineage"] = $(this).parents() .map(function () { return this.tagName; }) .get().reverse().join(" > "); $.ajax({url:"/cgi/position.pl" ,data:info ,dataType:"json" ,type:"POST" ,success: function(data){ $("#tag").append(data.status + " ") } }); evt.cancelBubble = true; // NEW! if (evt.stopPropagation) evt.stopPropagation(); }); }); // ]]>

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://650915]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2020-08-06 08:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (39 votes). Check out past polls.

    Notices?