SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast cliffgs's Avatar
    Join Date
    Aug 2003
    Location
    West Coast, New Zealand
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can someone help me with this code, please?

    Hi

    I have this JavaScript which seems to work OK in NN 7.x on the Mac but refuses to even do anything on IE on the Mac.

    To see what I am trying to do, please goto www.c-c-strange.biz, go to the Photographs page and then the Christchurch link.

    The caption to the right of the photo is currently a jpeg, I want to change it to html.

    As I say, this works in Netscape:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <title>Christchurch Scenes</title>

    <removed style setting to save space>

    <script type="text/javascript" language="JavaScript">
    <!--
    var image_dir = ""
    var numImages = 13;
    var num=1

    image1 = new Image(255,383);
    image1.src = image_dir + "02.jpg";
    image2 = new Image(255,383)
    image2.src = image_dir + "01.jpg";
    image3 = new Image(255,383)
    image3.src = image_dir + "03.jpg";
    image4 = new Image(255,383)
    image4.src = image_dir + "05.jpg";
    image5 = new Image(255,383)
    image5.src = image_dir + "04.jpg";
    image6 = new Image(255,383)
    image6.src = image_dir + "06.jpg";
    image7 = new Image(255,383)
    image7.src = image_dir + "07.jpg";
    image8 = new Image(255,383)
    image8.src = image_dir + "09.jpg";
    image9 = new Image(255,383)
    image9.src = image_dir + "08.jpg";
    image10 = new Image(255,383)
    image10.src = image_dir + "10.jpg";
    image11 = new Image(255,383)
    image11.src = image_dir + "11.jpg";
    image12 = new Image(255,383)
    image12.src = image_dir + "12.jpg";
    image13 = new Image(255,383)
    image13.src = image_dir + "13.jpg";

    text1 = "Cap02.html";
    text2 = "Cap01.html";
    text3 = "Cap03.html";
    text4 = "Cap05.html";
    text5 = "Cap04.html";
    text6 = "Cap06.html";
    text7 = "Cap07.html";
    text8 = "Cap08.html";
    text9 = "Cap09.html";
    text10 = "Cap10.html";
    text11 = "Cap11.html";
    text12 = "Cap12.html";
    text13 = "Cap13.html";
    function slideshowNext() {
    num=num+1;
    if (num == 14) {
    num=1;
    }
    document.mypic.src=eval("image" + num+ ".src");
    /* document.getElementById("captxt").src=eval("text" + num);*/
    }
    function slideshowBack() {
    num=num-1;
    if (num==0) {
    num=13
    }
    document.mypic.src=eval("image" + num+ ".src");
    /* document.getElementById("captxt").src=eval("text" + num);*/
    }

    // -->
    </script>

    </head>
    <body>

    <div id="navcontainer">
    <ul id="navlist">
    <li><a href="../index.html">Home</a></li>
    <li><a href="../photographs.html">Photographs Index</a></li>
    </ul>
    </div>
    <div id="picbox">
    <img id="mypic" src="02.jpg" alt="" width="255" height="383" border="1" />
    </div>

    /*<div id="capbox">
    <iframe src="Cap02.html" id="captxt" width="300" height="389" frameborder="no"></iframe>
    </div>
    */
    <div id="navbuttons">
    <a href="JavaScript:slideshowBack()">&lt;&lt;Back | </a>
    <a href="JavaScript:slideshowNext()">Next&gt;&gt;</a>
    </div>

    </body>
    </html>

    Any help for this newbie would be greatly appreciated.

    Thanks in advance

    Cliff Strange
    TypeShop Limited
    Christchurch
    New Zealand

  2. #2
    SitePoint Evangelist Aska's Avatar
    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tested the page in Mozilla and IE. Like you said it doesn't work in IE but works okay in Mozilla. When I press "Next" on IE an error message shows up saying that "Interval" is undefined
    Code:
    function rotateImage(place, placeCap) {
      var new_image = getNextImage();
      document[place].src = new_image;
      var new_cap = getNextCap();
      document[placeCap].src = new_cap;
      var recur_call = "rotateImage('"+place+"')";
      timerID = setTimeout(recur_call, interval); // this line!
    }
    Try putting this line before the timerID = ... code:
    Code:
      var interval = 15000;
    Hope that helps.

  3. #3
    SitePoint Enthusiast cliffgs's Avatar
    Join Date
    Aug 2003
    Location
    West Coast, New Zealand
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I will take note of that and change it if I have to stick with the existing setup. But that code is from the current way I am doing things. It is the code that I posted in my original post that is the real problem - because I would really like to make the captions html and not jpegs.

    Thanks

    Cliff

  4. #4
    SitePoint Evangelist Aska's Avatar
    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops, I just assumed that they were the same code. My apologies.

    BTW, what exactly isn't working in IE? I noticed that you have the caption text loader code commented out...

    If it's the caption loader, you may like to try giving the <iframe> a name attribute e.g. <iframe name="captxt" id="captxt"></iframe> and then in your javascript do something like:
    Code:
     document.mypic.src=eval("image" + num+ ".src" );
    window.open( eval( 'text'+num), 'captxt'); // this is the new code
    Cheers~

  5. #5
    SitePoint Enthusiast cliffgs's Avatar
    Join Date
    Aug 2003
    Location
    West Coast, New Zealand
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Aska! That was the clue I needed.

    I gave the iframe a name as well as an id, and it worked (with my existing code).

    I had commented out the code to try and resolve what wasn't working, and I unfortunately forgot to uncomment it when I posted it to this forum.

    But your suggestion of using name as well as id made it work :-)))

    Is there a good place to find out about all the differences in JavaScript between browsers. I now find it doesn't work so well in either Safari or Opera. But I think I could track that down if I had some reference material.

    Many thanks for your help.

    Cliff
    TypeShop Limited
    Christchurch
    New Zealand

  6. #6
    SitePoint Evangelist Aska's Avatar
    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Glad to help~

    Good reference if you are after a list of functions:
    http://www.devguru.com/Technologies/...ipt_index.html

    This site shows what works in what browsers (click on the links on the right hand side of the page) - however doesn't say much about browsers other than IE/NN.
    http://www.irt.org/xref/index.htm

    I'd be interested if other people knows of any site that lists/compares the differences in JavaScript/DOM across different browsers.


Bookmarks

Posting Permissions

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