unrelativity
unrelativity

Reputation: 3720

document.viewport.getHeight() inaccurate?

In regards to the demo of Scriptaculous' Effect.Move which can be found here:

<style type="text/css">
  a#move_demo { background:#fa0000; color:#fff; padding:5px; border:1px solid #000; }
</style>

<div class="demo">
  <a href="#" id="move_demo" onclick="new Effect.Move(this, { x: 60, y: -30 }); return
false;">Click me for a demo!</a>
</div>

With a single page containing that, document.viewport.getHeight() returns 32, while for width, it's fine.

Why is this the case? Shouldn't it be the height of viewport, not the height from top of the document to the bottom?

Is there a workaround?

Upvotes: 2

Views: 1806

Answers (1)

unrelativity
unrelativity

Reputation: 3720

Turns out you need a correct DOCTYPE to make it work properly, otherwise Prototype will be in "quirks mode" which doesn't let getheight() work as intended.

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

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

Upvotes: 6

Related Questions