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!

image in javascript

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>
 
Correct me if Im wrong but dont you need to write it to the document?

<html>
<head>
<script language=&quot;javascript&quot;>
if (screen.width > 800)
{
document.write(&quot;<img src='images/untitled2.gif'><FONT COLOR='#006699'>&quot;)
}
if (screen.width < 800)
{
document.write(&quot;<img src='images/untitled2test.gif'><FONT COLOR='#006699'>&quot;)
}
</script>
</head>
</html>
 
Thanks and good thought but that didn't work.
Somehow I think it doesn't like the image tags but I'm not sure.

Thanks..Russ
 
Looks like my screen wasn't refreshing or something. When I checked it this morning what you siad was right.

Thanks..Russ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top