1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Basic javascript works in IE but not Netscape or FireFox

Discussion in 'Software Development' started by DrP, Aug 19, 2005.

Thread Status:
Not open for further replies.
Advertisement
  1. DrP

    DrP Thread Starter

    Joined:
    Jul 23, 2005
    Messages:
    739
    Hi. I'm trying to learn some basic javascript. I've adapted some code from a member of this forum which changes the source of a large picture when a thumbnail is clicked on.
    For now I'm testing it with coloured squares. In IE the page is working perfectly but when the thumbs are clicked in either Netscape or FireFox nothing happens. Can anyone help? Please!
    Here's the link
    http://www.cliveportman.co.uk/clive_site/home.html
     
  2. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    Link isn't working.
     
  3. ggordie

    ggordie

    Joined:
    Jul 16, 2005
    Messages:
    143
    ur probly using Jscript, microsofts version of javascript. javascript was invented by mozilla, th company that makes firefox and netscape, so it's unlikely that javascript isnt working on your mozilla browsers. jscript and javascript are almost the same, but not entirely, so they're easily confused.
     
  4. DrP

    DrP Thread Starter

    Joined:
    Jul 23, 2005
    Messages:
    739
  5. aewarnick

    aewarnick

    Joined:
    Sep 3, 2002
    Messages:
    828
    In programming, when something is not defined it means that a variable was created but has no definition (there is no telling what KIND of variable it is).

    Are you able to post some code?
     
  6. DrP

    DrP Thread Starter

    Joined:
    Jul 23, 2005
    Messages:
    739
    Sure. This is in the <head>:

    <script type="text/javascript">
    function changeImage(filename)
    {
    big_image.src = filename;
    }
    </script>

    And I call the script by clicking on this thumbnail:

    <a href="javascript:changeImage('photos/wells_castle.jpg')">
    <img src="thumbs/wells_castle_thumb.jpg" alt="Wells Castle"/></a>

    And the Big_image is here, which shows the larger photograph:
    <div id="main_image">
    <img id="big_image" src="../white_square.gif" alt=""/>
    </div>

    Does that help?
     
  7. aewarnick

    aewarnick

    Joined:
    Sep 3, 2002
    Messages:
    828
    Where is big_image declared: var big_image? If it was never declared, that's your problem.
     
  8. aewarnick

    aewarnick

    Joined:
    Sep 3, 2002
    Messages:
    828
    Try this:

    var big_image = new Image();
    big_image.src = filename;

    I'm not sure that will work, but it's worth a try.
     
  9. DrP

    DrP Thread Starter

    Joined:
    Jul 23, 2005
    Messages:
    739
  10. aewarnick

    aewarnick

    Joined:
    Sep 3, 2002
    Messages:
    828
    Did you try:

    <script type="text/javascript">
    var big_image=new Image();
    function changeImage(filename)
    {
    big_image.src = filename;
    }
    </script>

    AND

    <script type="text/javascript">
    function changeImage(filename)
    {
    var big_image=new Image();
    big_image.src = filename;
    }
    </script>
     
  11. DrP

    DrP Thread Starter

    Joined:
    Jul 23, 2005
    Messages:
    739
    Yes, tried both of those but to no avail. Have, however, solved it 10 min ago. I just changed big_image.src = filename to document.images.big_image.src = filename and it works in both Netscape and Firefox!
    Get in there!
    DrP
     
  12. aewarnick

    aewarnick

    Joined:
    Sep 3, 2002
    Messages:
    828
    Glad you found the problem! (y)

    That is why it worked in IE but noone else. IE does not follow standard like they should.
     
  13. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/391682