Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-09-2006, 09:08 PM   PM User | #1
kaitco
Regular Coder

 
Join Date: Dec 2005
Location: Ohio
Posts: 286
Thanks: 7
Thanked 9 Times in 9 Posts
kaitco is on a distinguished road
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!
kaitco is offline   Reply With Quote
Old 12-09-2006, 10:16 PM   PM User | #2
david_kw
Senior Coder

 
Join Date: Nov 2006
Posts: 1,000
Thanks: 0
Thanked 0 Times in 0 Posts
david_kw will become famous soon enough
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
david_kw is offline   Reply With Quote
Old 12-09-2006, 10:34 PM   PM User | #3
david_kw
Senior Coder

 
Join Date: Nov 2006
Posts: 1,000
Thanks: 0
Thanked 0 Times in 0 Posts
david_kw will become famous soon enough
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
david_kw is offline   Reply With Quote
Old 12-10-2006, 02:18 AM   PM User | #4
kaitco
Regular Coder

 
Join Date: Dec 2005
Location: Ohio
Posts: 286
Thanks: 7
Thanked 9 Times in 9 Posts
kaitco is on a distinguished road
Thanks a lot!
kaitco is offline   Reply With Quote
Old 12-11-2006, 12:33 AM   PM User | #5
VR2
New Coder

 
Join Date: Jul 2006
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
VR2 is an unknown quantity at this point
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).
VR2 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 08:37 AM.


Advertisement
Log in to turn off these ads.