Results 1 to 2 of 2

Thread: Javascript: Images not showing up online. Show up on hard drive?????????????

  1. #1
    Join Date
    Nov 2007
    Posts
    2

    Question Javascript: Images not showing up online. Show up on hard drive?????????????

    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.

    Code:
    <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>

  2. #2
    Join Date
    Mar 2008
    Location
    Albuquerque, NM
    Posts
    4
    Quote Originally Posted by jb33314
    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.

    Code:
    <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>
    I made the one glaring problems in red.

    1: Your variable definition isn't completely quoted.
    2: I'm not sure if that needs to be quoted, or if you just mistyped the definition in the previous code.

    That's all I caught. See if it magically fixes the problem (It could -- PHP gives some nasty MySQL errors even if you miss one semicolon 20 lines previous to the query in the script).

    Regards.

Similar Threads

  1. New images not showing up?
    By KOOKMON in forum General Questions
    Replies: 1
    Last Post: 16 Dec 2007, 05:42 AM
  2. Replies: 1
    Last Post: 16 Jul 2007, 02:46 PM
  3. without JavaScript online form
    By Panospheric in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 11 May 2007, 04:28 AM
  4. Help with cut and paste javascript slide show on my site?
    By Ella in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 29 Aug 2006, 10:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •