center
Anyone know a crossbrowser way to display a variable object (ie. an image) in the center of the browser screen without using frames?
Thanks in advance!
Shakespeare: onclick || !(onclick)
Anyone know a crossbrowser way to display a variable object (ie. an image) in the center of the browser screen without using frames?
Thanks in advance!
Shakespeare: onclick || !(onclick)
Vincent Puglia posted this at 14:47 — 20th December 2001.
They have: 634 posts
Joined: Dec 1999
Hi Jack,
If my sense of geometry is still good (and if I'm awake enough , this should work:
var winWidth = ( (document.layers) || (document.getElementById)) ? window.innerWidth : document.body.clientWidth;
var winHeight = ( (document.layers) || (document.getElementById)) ? window.innerHeight : document.body.clientHeight;
var winXCenter = winWidth/2;
var winYCenter = winHeight/2;
var imgWidth = imgObj.width;
var imgHeight = imgObj.height;
var xCenter = winXCenter - (imgWidth/2)
var yCenter = winYCenter - (imgHeight/2)
Vinny
Where the world once stood
the blades of grass cut me still
Jack Michaelson posted this at 21:07 — 20th December 2001.
He has: 1,733 posts
Joined: Dec 1999
I was thinking about that one... but didn't know precisely and I was too lazy to check and work it out
thanx!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.