Results 1 to 5 of 5

Thread: onmouse over element

  1. #1
    Join Date
    Mar 2006
    Location
    UK, warwickshire
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default onmouse over element

    i need to be able to find out if the mouse is over an element.

    would it be something like
    Code:
    doument.getElemntById('id').mouseover
    thanks for any help

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    doument.getElemntById('id').onmouseover=function(){alert('Ta Da!');}
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2006
    Location
    UK, warwickshire
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks but i need to be able to use it in if

    Code:
    if (doument.getElemntById('id').mouseover)
    {
        alert('ok')
    }
    else 
    {
       alert('end')
    }

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Unless you want to track the position of the mouse over the document which is rather resource intensive but can be done, comparing it to the x, y, rightedge and bottomedge of your element, you can just create a global variable:

    Code:
    var overel=0;
    Then either through script, as in my previous example, or in the HTML code, assign onmouseover and onmouseout events to your element which include (they can do other things as well) for example in HTML:

    HTML Code:
    <div onmouseover="overel=1" onmouseout="overel=0">Content for this division</div>
    Then you can do:

    Code:
    if (overel)
    {
        alert('ok')
    }
    else 
    {
       alert('end')
    }
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Mar 2006
    Location
    UK, warwickshire
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    WOW i was dumb when i posted this question lol. normal i would of just used your first reply and done what you did in you second post. thanks anyway

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •