jb33314
02 Mar 2008, 05:18 PM
I am making a navigation bar using Javascript. Nothing fancy. No drop down menus or any thing like that. All it does is read a cookie (cookie reading works so thats not the problem) and loads a certain image based on the data of the cookie.
This works fine when the webpage is stored locally on my computer. I even tried it locally on other computers. The problem is when I upload the page to a host the images dont show up. I tried taking one of the images out of the Javascript if statements and into the html directly. Then the image worked. So it cant be my src path to the image is wrong. Heres some code to show you how my page works.
<html><head>
<script type="text/javascript">
var theme;
(pseudocode)
if(cookie exists){theme=cookievalue;}
else{theme="theme1; cookievalue=theme;}//if cookie doesnt exisit creat a cookie with the default value
(/end pseudocode)
</script>
</head><body>
//some html here
<script type="text/javascript">
if(theme == "theme1")
{
document.write( "<img src=\"theme1im1.gif\" onMouseover=\"this.src='theme1im2.gif'\">");
}
else//theme="theme2"
{
document.write( "<img src=\"theme2im1.gif\" onMouseover=\"this.src='theme2im2.gif'\">");
}
</script>
</body>
</html>
This works fine when the webpage is stored locally on my computer. I even tried it locally on other computers. The problem is when I upload the page to a host the images dont show up. I tried taking one of the images out of the Javascript if statements and into the html directly. Then the image worked. So it cant be my src path to the image is wrong. Heres some code to show you how my page works.
<html><head>
<script type="text/javascript">
var theme;
(pseudocode)
if(cookie exists){theme=cookievalue;}
else{theme="theme1; cookievalue=theme;}//if cookie doesnt exisit creat a cookie with the default value
(/end pseudocode)
</script>
</head><body>
//some html here
<script type="text/javascript">
if(theme == "theme1")
{
document.write( "<img src=\"theme1im1.gif\" onMouseover=\"this.src='theme1im2.gif'\">");
}
else//theme="theme2"
{
document.write( "<img src=\"theme2im1.gif\" onMouseover=\"this.src='theme2im2.gif'\">");
}
</script>
</body>
</html>