SitePoint Sponsor

User Tag List

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

    Why doesn't this work on IE? 2 problems

    Well, check this page out.

    If you open it with Opera, everything works great. When you click the button, that "layer" moves 100px downward, like it's supose to.

    But when you open it with IE and click the button for the first the 1. problem becomes obvious: the div is 100px high and it should move 100px downward (so the top of the div should be just where the bottom of the div was). But it doesn't!

    When you press the button for the second time, an error occures and the div doesn't move.

    Please help

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should help a little bit...
    Code:
    <script type="text/javascript">
    var O  = navigator.userAgent.toLowerCase().indexOf('opera') != -1;
    function dom(objectID) {
    	if(document.layers){ if(document.layers[objectID]) return document.layers[objectID]; }
    	if(document.all) return document.all[objectID].style;
    	return document.getElementById(objectID).style;
    }
    function move() {
    	if(O||document.all) dom('moj1').pixelTop = dom('moj1').pixelTop + 100;
    	else      dom('moj1').top = dom('moj1').top + 100;
    }
    </script>
    ----Adopt-a-Sig----
    Your message here!

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

    a couple of questions

    First of all, what is that var O doing there? It already works fine on Opera.

    Why do I have to use document.all for IE to work when in my other scripts document.getElementById works just fine on IE.

    So basically what you wrote here is cross browser DOM.
    Yesterday I asked on this forum if I have to write cross browser DOM for latest browsers and the answer was no. Why is that different here?

  4. #4
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1)The check for opera makes the code work in all DHTML capable versions of Opera.

    2)Only IE6 (if memory serves) supports the getElementById() function.

    3)If you want a cross-browser app, you have to use cross-browser code. There's no magical way around that. I'm guessing that either you weren't clear is what you were asking, or else the person who answered you wasn't clear in answering.

    The fact is that IE, Netscape/Mozilla, Opera, Konqueror, and a number of other browsers all have large numbers of users, making them valid development targets, yet they all have such a hard time agreeing on how code should work.

    Writing to standards means ruling out cross-browser support, and vice versa. The two are mutually exclusive.
    ----Adopt-a-Sig----
    Your message here!

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

    adjustment :)

    Now that I know that IE uses pixelTop instead of top, I made a slight change and works just as good:

    ------------------------------------------------------------------------
    <script>
    //first determine if it is IE or any other browser
    if ((navigator.appName.indexOf('Microsoft') != -1) && (navigator.userAgent.toString().indexOf('Opera') == -1)) {a = 2;}
    else {a = 3;}
    </script>

    <script>
    function dom(objectID) {return document.getElementById(objectID).style;}

    function move() {if (a == 3) {dom('moj1').top = dom('moj1').top + 100;}
    else {dom('moj1').pixelTop = dom('moj1').pixelTop + 100;}}
    </script>
    ------------------------------------------------------------------------

    As simple as that

  6. #6
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by randem
    Only IE6 (if memory serves) supports the getElementById() function.
    IE 5+ (Mac/PC)
    plus of course, NS6+, Mozilla (all versions), Opera 4+ (depending on mode)
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  7. #7
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Bill Posters
    IE 5+ (Mac/PC)
    plus of course, NS6+, Mozilla (all versions), Opera 4+ (depending on mode)
    Naturally, Mozilla and Opera... what I meant was "version 6 of IE" and not previous versions (save only 5+ Mac).

    I wonder why they fragmented their browser support so much?

    What director of development said "we'll make version 5 on the Mac do everything, but the Windows users... those who are paying our salaries... they will get very little support, even a full version later!"?
    ----Adopt-a-Sig----
    Your message here!

  8. #8
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by randem
    Naturally, Mozilla and Opera... what I meant was "version 6 of IE" and not previous versions (save only 5+ Mac).
    I'm 99.999...% sure that version 5 for PC supports getElementById() too.
    I use it as a entry browser/object sniffer on my own site to separate those browsers that support W3C DOM from those that don't.
    Code:
    if (document.getElementById) {...
    As far as I know, IE5 PC users are getting through without problems and able to use my site without any problems with the DOM.

    What director of development said "we'll make version 5 on the Mac do everything, but the Windows users... those who are paying our salaries... they will get very little support, even a full version later!"?
    As I understand it, the Mac IE team is a near autonymous group of developers who are left to get on with things at their own speed.
    I believe they also are more sympathetic to the W3C agenda than their 'for Windows' counterparts.
    They seem to be free from the bureaucracy and 'politics' that seem to be stunting IE for Windows growth.

    It seems to be working in the Mac's favour this time

    Huzzah!
    Last edited by Bill Posters; Aug 31, 2002 at 06:51.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  9. #9
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Bill Posters
    As I understand it, the Mac IE team is a near autonymous group of developers who are left to get on with things at their own speed.
    I believe they also are more sympathetic to the W3C agenda than their 'for Windows' counterparts.
    They seem to be free from the bureaucracy and 'politics' that seem to be stunting IE for Windows growth.
    That's my point... I want to know what crazy circumstances and planetary alignment have to occur for two groups to work on the same product but have absolutely no relation or communication with each other. Any other company would call this an absurd development practice!

    It seems to be working in the Mac's favour this time
    Yeah, so I guess I should keep my voice down for fear that they realize how stupid they are and change it! Aw, who am I kidding? MS will never realize how stupid they are... they'll just spin it into another twisted story about how right they are and we the consumers were once again too blind to see it!
    ----Adopt-a-Sig----
    Your message here!


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
  •