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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SET IMAGE BASED ON SCREEN RESOLUTION

Status
Not open for further replies.

rry2k

Programmer
Jun 28, 2001
678
US
Hi,

I am trying to set image sizes based on screen resolution per help I received in a previous message. The code I have now that doesn't work is listed below. With the images outside of the Javascript the images display fine but not within the tags.

<html>
<head>
<script language=&quot;javascript&quot;>
if (screen.width > 800)
{
<img src=&quot;images/untitled2.gif&quot;><FONT COLOR=&quot;#006699&quot;>;
}
if (screen.width < 800)
{
<img src=&quot;images/untitled2test.gif&quot;><FONT COLOR=&quot;#006699&quot;>;
}
</script>
</head>
</html>
 
Try putting the tags within a
Code:
document.write()
call.
As it is now the browser tries to interpret the tags as javascript and not as html.
Code:
if (screen.width > 800)
{
document.write('<img src=&quot;images/untitled2.gif&quot;><FONT COLOR=&quot;#006699&quot;>');
}
Good luck!
 
That did the trick.

Thanks..Russ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top