plz anybody helppppp me
I want to have script to grab information of object and viewed at "status bar"(or other) about all active element properties of object if mouse over it.
example:
If cursor on Object1, the status will show like :
ID="myDiv1" style="color:#CCCCCC"
If cursor on Object2 status will :
Name:"myText1" Value:"textValue1"
If cursor on Object3 status will :
Src="myImage.gif" width="149" height="173" border="0" alt="myImage"
the result is can be status or maybe alert, but the only conditional is : each object must not have any javascript statement/function, so i think is like "event listener" (correct me if wrong) and initialize on window.onload
Is that possible to make script for this ??? please help me
A quick example of adding the listener to your DIV using DOM2 Events (as implemented by Gecko - NS6, NS7, Mozilla, Beonex, K-meleon, and Galeon):
window.onload = function() {
function myListener(event) {
window.status = event.target.nodeName;
// do anything
}
The 3rd argument in the addEventListener method represents useCapture, but since IE doesn't support capturing, I'm trying to make both events be pretty much identical crossbrowser.
As for IE, you will need to make use of proprietary methods:
window.onload = function() {
function myListener(event) {
window.status = (event.target || event.srcElement).nodeName;
// do anything
}
var refToDiv = (document.getElementById || document.all)('myDiv1');
if (typeof document.implementation != 'undefined' && document.implementation.hasFeature('Events', '2.0'))
refToDiv.addEventListener('mouseover', myListener, false);
else if (typeof document.attachEvent != 'undefined')
refToDiv.attachEvent('onmouseover', myListener);
}
:)
Also, since this deals with Event listners, I think I'll move this to the DOM Scripting forum.
(I'm trying to set a precedent of which threads are appropriate for it now, since you brought it up. :D)
thanks JKD, I've try your code,
but i still not like what i need,
I need script that can grab/capture elements/attributes with out giving ID of that Object,
I just wondering to know, is that is possible or not ?
cause i think : if can make event listening for event handler action,....... so..... why can not identify from which object the event handler action come from ????? Or is that truly Impossible
Notice now that the status bar reflects the objects you are mousing over, in Gecko at least. The mouseover event is capturing down the document tree, and you are receiving that event as it passes through its first node on the way down to the target element (because useCapture is true).
Is that sort of along the lines you were talking about?
THANKSSSSS jkd ...... that what i need.......
BTW,.. anybody...... plz tell me where i can get the good article about "event Bubble" ...!!!???
I don't know a link offhand, but I can quickly explain it:
In the DOM2 Events model, events "capture", then "bubble". When an event captures, it passes from the topmost node (document), down the target node. For example: