dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Web
Expertise: Beginner
Apr 22, 2002

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Use Any Image as a Background


This code allows any image to be used as a background, and scales that image to fit the browser. Just add it to the end of your HTML page:
  
<!-- add this to end of html --> 
<div id="scale_bg"><img name="bgImage" src="scale_bg5.jpg" height="100%" 
width="100%" border="0"></div> 
<script language="JavaScript"> 
<!-- hide script from old browsers 

   if (document.all) { 
      document.all("scale_bg").style.visibility = "visible"; 
      } 
   else if (document.layers) { 
      document.layers["scale_bg"].visibility = "show"; 
      } 

function scaleBG() { 
      if (document.all) { 
                 document.all("scale_bg").style.left = 0; 
         document.all("scale_bg").style.top = 
document.body.scrollTop; 
         document.all("scale_bg").style.width = 
document.body.clientWidth; 
         document.all("scale_bg").style.height = 
document.body.clientHeight; 
         } 
      else if (document.layers) { 
         document.layers["scale_bg"].left = 0; 
         document.layers["scale_bg"].top = window.scrollTop; 
         document.layers["scale_bg"].width = 
window.innerWidth; 
         document.layers["scale_bg"].height = 
window.innerHeight; 
         } 
      setTimeout('scaleBG()',300); 
      } 

if (document.all||document.layers) 
window.onload = scaleBG; 
window.onresize = new Function("scaleBG();"); 
// end hiding from old browsers --> 
</script> 
<style type="text/css"> 
#scale_bg { 
position:absolute; 
z-index:-1; 
left:0; 
top:0; 
visibility:hide; 
visibility:hidden; 
width:40; 
height:40; 
} 
</style> 
Michael Bradley
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date