Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Location
    Ohio
    Posts
    286
    Thanks
    7
    Thanked 9 Times in 9 Posts

    Doctype "breaks" javascript?

    What troubleshooting measures can I take when a script seems to break if a proper Doctype is used?

    For example, if I use a game script precisely as it is offered, it works perfectly, sans Doctype, like here. However, if I add a doctype to the page, like here, the script no longer works correctly. The problem also persists across browsers.

    So, I am wondering what, if anything, I can do to ensure that a script works correctly with a Doctype, even if it was created without one?

    Many thanks!

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's a wild one. It appears that when you add the DOCTYPE it makes clientHeight go to zero in IE7 and FF1.5 and FF2. Interestingly it works in IE6. Go figure.

    So what is happening in the code is as soon as you move the piece the code decides you are outside the client window (since the mouse y is greater than the client height which it thinks is zero). So it immediately drops it back on the stack.

    So I found this link

    http://www.softcomplex.com/docs/get_..._position.html

    Maybe you can pull something out of there to fix it. Either that or get rid of the check in dragDisk() that is around 190 that drops the disk if it leaves the screen.

    david_kw

  • #3
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That site seems to suggest when you have DOCTYPE that you have to start checking

    document.documentElement.clientHeight

    instead of

    document.body.clientHeight

    david_kw

  • #4
    Regular Coder
    Join Date
    Dec 2005
    Location
    Ohio
    Posts
    286
    Thanks
    7
    Thanked 9 Times in 9 Posts
    Thanks a lot!

  • #5
    VR2
    VR2 is offline
    New Coder
    Join Date
    Jul 2006
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah the DOCTYPE declaration has IE move to "standards Mode" instead of "Quirks Mode" and it moves alot of stuff, especially from body, to documentElement.

    One thing I was never able to get (my head) around though was that when using a DOCTYPE, the body tag could specify no scroll (bars) like this

    Code:
    <body scroll=no>
    But there seems to be no way in code to do the same thing (turn off scrollbars for a document after the page is loaded).


  •  

    Posting Permissions

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