View Full Version : dynamic image resize problem

06-20-2009, 09:20 AM
I'm trying to do several things with an image on my page.

1) it is in an iframe
2) it resizes dynamically when the parent page does
3) it randomly selects the image with a php script

the image is used as a background in the iframe and so should take up 100% of the space inside it. I had problems trying to resize a background image and so it's a z-indexed image instead. The problem is that the image shows up very small in the top left corner until the window is resized, then it resizes perfectly as it should. I used different scripts and snippets that I found on the web so it's hacked together and kinda strange probably, but heres the relevant code I think. Please tell me if you know why the image is misbehaving.

http://sharadon.l4rge.com (my page)

http://www.boutell.com/newfaq/creating/backgroundfill.html (script for resizing the background image)

The code for finding the window size
function GetWidth()
var x = 0;
if (self.innerHeight) { x = self.innerWidth; }
else if (document.documentElement && document.documentElement.clientHeight) { x = document.documentElement.clientWidth; }
else if (document.body) { x = document.body.clientWidth; }
return x;

function GetHeight()
var y = 0;
if (self.innerHeight) { y = self.innerHeight; }
else if (document.documentElement && document.documentElement.clientHeight) { y = document.documentElement.clientHeight; }
else if (document.body) { y = document.body.clientHeight; }
return y;

function changeWidth() {
var i = GetWidth()-195;

function changeHeight() {
var i = GetHeight()-161;

and finally the php random background script is at http://www.marcofolio.net/webdesign/php_random_image_rotation.html

It's driving me nuts that stupid little image :P