View Full Version : Object required IE6

Mar 15th, 2007, 09:02 PM
I'm using Prototype to change the margin of an element based on the viewport height when the window loads. It works fine in Firefox, but I get an "Object required" error in IE6. I've been testing it with alerts.

<script type="text/javascript">

var Client = {
viewportWidth: function() {
return self.innerWidth || (document.documentElement.clientWidth ||

viewportHeight: function() {
return self.innerHeight || (document.documentElement.clientHeight
|| document.body.clientHeight);

viewportSize: function() {
return { width: this.viewportWidth(), height:
this.viewportHeight() };


var winHeight = Client.viewportHeight(); // The one below wasn't working so I tried this, same "Object required"
//var new_margin = Math.max(0, (Client.viewportWidth()/2)-268);
//var new_margin = 175;
//var new_margin = winHeight;

function init() {
// marginTop: new_margin + 'px'


window.onload = init;

Mar 15th, 2007, 09:09 PM
It works for me in IE6.

Mar 16th, 2007, 12:31 AM
glenngv did you just copy and paste it into a blank HTML document? I just did the same and got the same error.