Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Webpage Element Information

by erroneousBollock (Curate)
on Nov 15, 2007 at 04:37 UTC ( [id://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 (Archbishop) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://650915]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-26 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found