PDA

View Full Version : Object required IE6



andymadonna
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 ||
document.body.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() {
alert(Client.viewportHeight());
//alert(new_margin);
alert(winHeight);
//$('timeline').setStyle({
// marginTop: new_margin + 'px'
//});

}

window.onload = init;
</script>

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

andymadonna
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.