Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help for background image resolution

Status
Not open for further replies.

taz97

Programmer
Jun 7, 2001
17
CA
Hi, I would like to know how replace these line (window.location.replace...) by a image. If the resolution is 800x600, I will use a 800x600 image for background and the same thing
for other resolution !
Thanks !

if (screen.width==800||screen.height==600) //if 800x600
window.location.replace("
else if (screen.width==640||screen.height==480) //if 640x480
window.location.replace("
else if (screen.width==1024||screen.height==768) //if 1024x768
window.location.replace("
else //if all else
window.location.replace("
 
hi taz97,
If you talk about background image of your webpage, you may do this:

if (screen.width==800||screen.height==600)
document.write('<body background=&quot;image1.gif&quot;>')

else if (...)
document.write('<body background=&quot;image2.gif&quot;>')
. . .

this script should be inserted right after </head> tag:
<html>
<head>
<title></title>
<script>
function check_res() {

//insert all your if's here
}
</script>
</head>
<script>check_res()</script>
. . .
html content
. . .
</body>
</html>

There's also another option: set CSS background-image property:
body { background-image: url(&quot;image1.gif&quot;) }

The code should be this:
<html>
<head>
<title></title>
<script>
if (screen.width==800||screen.height==600)
document.write('<style> body { background-image: url(&quot;image1.gif&quot;) } </style>')

else if (...)
document.write('<style> body { background-image: url(&quot;image2.gif&quot;)')
//. . .
//insert all your if's here
</script>
</head>
<body>
. . .
</body>
</html>

good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top