DOCTYPE problem, jQuery

Scroll.js is used for the #bird block that follows the page scrolling.

The main problem is it works if I remove the Doctype line it is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      

and it doesn't work if the doctype is included.

Here is the html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <script src="jquery.js" type="text/javascript"></script>
    <script src="scroll.js" type="text/javascript"></script>
</head>

<body>
<div style="position:relative; height:20000px">
    <div id="bird" style="position:absolute;left:0;top:20px;width:200px"></div>     
</div>
</body>
</html>

      

And js:

removed

Don't ask to remove the doctype, its .

0


source to share


2 answers


You need to replace this:

document.body.scrollTop

      

with this:



document.documentElement.scrollTop

      

scrollTop

refers to an element <html>

in standard mode, not an element <body>

.

(Note that it document.body.scrollTop

appears three times in your code.)

+3


source


there is one problem on your bird div, style had width: 200 "should be width: 200px" (add units)



0


source







All Articles