SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with API (finding one for IE and NS)

    I hope I used a proper title.

    I'm having difficulties with finding the proper atribut of an object with DOM. Like this example, which works on IE, Opera has hiccups, but in NS and Mozilla doesn't work at all (I'll show just the important parts):




    ----------------------------------------------------------------------
    <body bgcolor="white" onmousemove="move();">
    <div id="moj1"></div> <!-- which has styles defined. positioning included -->

    <script>
    function dom(objectID) {return document.getElementById(objectID).style;}
    function findYCoord(evt) {
    if (evt.y) return evt.y;
    if (evt.pageY) return evt.pageY;}

    function findXCoord(evt) {
    if (evt.x) return evt.x;
    if (evt.pageX) return evt.pageX;}



    function move() { dom('moj1').left = findXCoord(event);
    dom('moj1').top = findYCoord(event);}


    </script>
    ----------------------------------------------------------------------





    So I guess x or pageX doesn't work in NS. Which does?
    Do you use any conventions or programs or whatever to find out which properties in javascript does it support on different browsers?

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


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
  •