spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / dhtml / diner / bgresize
DHTML Diner Logo

This is a DHTML cross-browser technique. The in-page examples will only work in Navigator 4 and Explorer 4, all platforms.

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Background Image Resize (3)

The Complete Code

<HEAD>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
    NS4 = (document.layers);
    IE4 = (document.all);
    
    scaleWidth = true;
    scaleHeight = true;
    imSRC = "skiff.jpg";

    if (NS4) window.onload = setResize;

    function setResize(){
        setTimeout("window.onresize=reDo;",500);
    }

    function reDo(){
        window.location.reload()
    }

    if (IE4) window.onresize = reDoIE;

    function reDoIE(){
        imBG.width = document.body.clientWidth;
        imBG.height = document.body.clientHeight;
    }

    function makeIm() {
    
      winWid = (NS4) ? innerWidth : document.body.clientWidth;
      winHgt = (NS4) ? innerHeight : document.body.clientHeight;
    
      imStr = "<DIV ID=elBGim"
      + " STYLE='position:absolute;left:0;top:0;z-index:-1'>"
      + "<IMG NAME='imBG' BORDER=0 SRC=" + imSRC;
      if (scaleWidth) imStr += " WIDTH=" + winWid;
      if (scaleHeight) imStr += " HEIGHT=" + winHgt;
      imStr += "></DIV>";
    
      document.write(imStr);
    
    }
//-->
</SCRIPT>
</HEAD>

<BODY MARGINHEIGHT=0 MARGINWIDTH=0>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
    makeIm();
//-->
</SCRIPT>
.
. remainder of page HTML
.


Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

All Rights Reserved. Legal Notices.
Created: May 07, 1998
Revised: May 07, 1998

URL: http://www.webreference.com/dhtml/diner/bgresize/bgresize3.html