need to display id of the element under the pointer below the current pointer location

M

Mel

Is there a way of displaying the id of the element under the pointer ?

Please dont ask why I need it, but I do, i found tools that needs
installation that provide the same funcitonality. However, I would
like to turn on this feature using a flag in my url. Something like
debug=1.

thanks for your help
 
D

David Dorward

Mel said:
Is there a way of displaying the id of the element under the pointer ?

Please dont ask why I need it, but I do, i found tools that needs
installation that provide the same funcitonality. However, I would
like to turn on this feature using a flag in my url. Something like
debug=1.

Perhaps something along the lines of:

var el = document.getElementsByTagName('*');
for (var i = el.length - 1; i > -1; i--) {
if (el.id) {
el.title = el.id;
}
}
 
S

scripts.contact

Is there a way of displaying the id of the element under the pointer ?

Please dont ask why I need it, but I do, i found tools that needs
installation that provide the same funcitonality. However, I would
like to turn on this feature using a flag in my url. Something like
debug=1.

thanks for your help

try-

document.onmouseover=function(Event){
Event=(Event||event)
Eleme=Event.srcElement||Event.target
if(Eleme){
var idS=document.getElementById("showID")
idS.innerHTML="ID: "+(Eleme.id||"not found")
idS.style.display=''
idS.style.top= Event.clientY+10
idS.style.left=Event.clientX+10
}
}
document.onmouseout=function(){
document.getElementById("showID").style.display='none'
}
 
M

Mel

try-

document.onmouseover=function(Event){
Event=(Event||event)
Eleme=Event.srcElement||Event.target
if(Eleme){
var idS=document.getElementById("showID")
idS.innerHTML="ID: "+(Eleme.id||"not found")
idS.style.display=''
idS.style.top= Event.clientY+10
idS.style.left=Event.clientX+10
}
}
document.onmouseout=function(){
document.getElementById("showID").style.display='none'



}- Hide quoted text -

- Show quoted text -

Thats a nice piece of code. thanks a whole bunch.
I tried it with my app and i keep getting "Object Required" error
message.
Should I be making changes to your code or should it work the way it
is ?

i truely appreciate your help
 
S

scripts.contact

Thats a nice piece of code. thanks a whole bunch.
I tried it with my app and i keep getting "Object Required" error
message.
Should I be making changes to your code or should it work the way it
is ?


Create a div with id showID and style: position:absolute.

This should work:

<html><body id="BodyElement">
<script>
document.onmouseover=function(Event){
Event=(Event||event)
Eleme=Event.srcElement||Event.target
if(Eleme){
var idS=document.getElementById("showID")
idS.innerHTML="ID: "+(Eleme.id||"not found")
idS.style.display=''
idS.style.top= Event.clientY+10
idS.style.left=Event.clientX+10
}
}
document.onmouseout=function(){
document.getElementById("showID").style.display='none'
}
</script>

<a id="a_element">A Element</a><br>

<span id="span element">nt </span><b id="bold-text">BOLD TEXT</b>


<div id="showID" style="position:absolute;border:1px dashed
gray;background-color:white"></div>

</body></html>
 
M

Mel

Create a div with id showID and style: position:absolute.

This should work:

<html><body id="BodyElement">
<script>
document.onmouseover=function(Event){
Event=(Event||event)
Eleme=Event.srcElement||Event.target
if(Eleme){
var idS=document.getElementById("showID")
idS.innerHTML="ID: "+(Eleme.id||"not found")
idS.style.display=''
idS.style.top= Event.clientY+10
idS.style.left=Event.clientX+10
}
}
document.onmouseout=function(){
document.getElementById("showID").style.display='none'
}
</script>

<a id="a_element">A Element</a><br>

<span id="span element">nt </span><b id="bold-text">BOLD TEXT</b>

<div id="showID" style="position:absolute;border:1px dashed
gray;background-color:white"></div>

</body></html>- Hide quoted text -

- Show quoted text -

Thanks for the feedback. It tends to work fine on the top of a long
page. however as I scroll down absolute position kicks in and it
displays it in the scrolled area that is not visible !

do you have a Vaccine for this ?

Many Many thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top