Question

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

The main problem - it is working, if I remove the Doctype line, this one:

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

and it doesnt work if doctype is on.

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

Dont ask to remove the doctype, its needed.

Was it helpful?

Solution

You need to replace this:

document.body.scrollTop

with this:

document.documentElement.scrollTop

scrollTop belongs to the <html> element in standards mode, rather than the <body> element.

(Note that document.body.scrollTop appears three times in your code.)

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top