Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > need to display id of the element under the pointer below the current pointer location

Reply
Thread Tools

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

 
 
Mel
Guest
Posts: n/a
 
      04-21-2007
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

 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      04-21-2007
Mel wrote:

> 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[i].id) {
el[i].title = el[i].id;
}
}

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
 
 
 
scripts.contact
Guest
Posts: n/a
 
      04-21-2007
On Apr 21, 2:59 am, Mel <MelHer...@gmail.com> wrote:
> 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='n one'
}

 
Reply With Quote
 
Mel
Guest
Posts: n/a
 
      04-21-2007
On Apr 21, 7:16 am, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
> On Apr 21, 2:59 am, Mel <MelHer...@gmail.com> wrote:
>
> > 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='n one'
>
>
>
> }- 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

 
Reply With Quote
 
scripts.contact
Guest
Posts: n/a
 
      04-21-2007
On Apr 21, 12:27 pm, Mel <MelHer...@gmail.com> wrote:
>
> > 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='n one'

>
> > }-

>
> 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='n one'
}
</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>

 
Reply With Quote
 
Mel
Guest
Posts: n/a
 
      04-21-2007
On Apr 21, 2:00 pm, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
> On Apr 21, 12:27 pm, Mel <MelHer...@gmail.com> wrote:
>
>
>
>
>
>
>
> > > 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='n one'

>
> > > }-

>
> > 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='n one'
> }
> </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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Browser crashes with below code.What is wrong in below code. kiran Javascript 12 12-07-2011 02:38 PM
Pass mouse events through partially transparent element to element below blgroup@gmail.com Javascript 1 10-02-2007 01:36 AM
Location, location, location =?Utf-8?B?VHJhY2V5?= Wireless Networking 2 02-17-2007 08:37 PM
how can I put an element below another element, that's not absolutely positioned? felipevaldez@gmail.com Javascript 5 09-10-2006 01:56 AM
Could someone scan me a picture of the below? (Read Below) starlightvoyager@yahoo.com DVD Video 1 08-28-2006 05:42 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57