Software by jason, for jason.
Software
iPlaylist CopierJava Libraries
ItunesUtilitiesScripts
Bash Scripts
File Size File Size Test Free Space Line Counter List Copy MD5 Tool OS X Rotate Logs Rename It SnapshotPHP Scripts
Write Variable To File WWS MailerJavascript Scripts
WWS Background ScalerInteresting People
Admins
Phil GlocknerDesigners
Tonya Browning Catherine Chu Justin Cox Richard Georges Stephen Gray Jonathan Horak Justin Kiehl Andrea Spencer MeatheadDevelopers
Chris Austin Joost van Dongen Noah Figg Rick Hogge John Quarles Wayne Rittiman Joe Rivera Brent Schneeman David Scott Andy Skelton Pavan TumatiWWS Background Scaler
The World's Worst Software Background Scaler script attempts to make the background fill the width and height of the browser. This script is used on http://www.onejasonforsale.com and http://www.experimentalfutility.com. Simply upload the script to your webhost, link the script in your pages, and call the script's initialization in the background image's onLoad event.
Installation instructions and example usage are included within the zip file. (instructions are at the top of the .js file)
Requirements
The script is a javascript library, so visitors to your webpage without javascript enabled will not see the background scaling effects. Tips are provided within the installation instructions on how to still make the pages presentable for users with javascript disabled.
Download
wws bg scaler.zip [3.35 KB]
The Script
* World's Worst Software Javascript Background Scaler (C) Jason Baker 2007
*
* A background scaler that attempts to make the background fill the width
* and height of the browser. This library was written for the following sites:
* http://www.onejasonforsale.com
* http://www.experimentalfutility.com
* http://blunx.no-ip.com
*
* Feel free to use this library on your own sites!
*
* For updated versions of the library, visit
* http://www.worldsworstsoftware.com
*
* Updates:
* 2007/02/28
* - Initial Version.
*
* Usage Instructions:
* 1) Link to this library in the HEAD section of your page like so:
*
* <script type="text/javascript" src="wwsbgscaler.js" />
*
* 2) Place your background image inside of your BODY section, outside of any DIVs
* 3) Give your bottom-most div an id (for this example: "content")
* 4) Code your background IMG tag to call setupImageScaler like so:
*
* <img src="bg.jpg" style="position: absolute; top: 0px; left: 0px; visibility: hidden;"
* onLoad='setupImageScaler(this, "content", 100, true, true);'>
*
* Note: 100 in the line above is the pixel offset to add to the bottom dimension
* of the content div when calculating the background height. This gives
* you the ability to give your bottom most div some space between it and the
* bottom of the page.
*
* Note: it is a good idea to start the background image's visibility style
* off as "hidden" so non-javascript browsers won't show a unresized
* background image.
*
*/
var imageToResize;
var scaleX;
var scaleY;
var contentDiv;
var divOffset;
function getClientHeight()
{
return document.documentElement.clientHeight;
}
function getClientWidth()
{
return document.documentElement.clientWidth;
}
function getDivHeight()
{
return contentDiv.offsetHeight + (divOffset * 2);
}
function showImage()
{
imageToResize.style.visibility="visible";
}
function resizeImage()
{
//do the function twice in case one resize causes a blank space to be left
// where scrollbars were before the first resize
for (var i = 0; i < 2; i++)
{
if (scaleX)
{
if (imageToResize.width != getClientWidth())
{
imageToResize.width = getClientWidth();
}
}
if (scaleY)
{
var newHeight = Math.max(getDivHeight(), getClientHeight());
if (imageToResize.height != newHeight)
{
imageToResize.height = newHeight;
}
}
}
//document.getElementById('bgimage').height = Math.max(contentHeight, clientHeight);
}
/*
* image - the image object to scale
* div id - the id for the div to calculate content height from
* div_offset - the offset to add to the div height for total content height
* scale_x - boolean flag specifying whether to scale the image along the x axis or not
* scale_y - boolean flag specifying whether to scale the image along the y axis or not
*/
function setupImageScaler(image, div_id, div_offset, scale_x, scale_y)
{
imageToResize = image;
scaleX = scale_x;
scaleY = scale_y;
contentDiv = document.getElementById(div_id);
divOffset = div_offset;
resizeImage();
showImage();
onresize = function() { resizeImage(); }
onload = function() { resizeImage(); }
}