Results 1 to 7 of 7

Thread: JavaScript - IE/MAC will not display.

  1. #1
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JavaScript - IE/MAC will not display.

    Hi all....

    The following Javascript does not seem to work using IE on a MAC. The images do not display. Seems to work OK using Safari and all browsers on a PC.

    The script creates a slideshow of images.

    Any suggestions? Much appreciated!....

    <script type="text/javascript"><!--
    function GotoPic(Num){
    location.href=location.pathname+'?'+Num;
    }

    N=-1;Picture=new Array;
    N++;Picture[N]="imagename.jpg";
    N++;Picture[N]="imagename2.jpg";
    N++;Picture[N]="imagename3.jpg";
    N++;Picture[N]="imagename4.jpg";

    var ThisPic;
    var PrevPic;
    var NextPic;
    var ShowPrev;
    var ShowNext;

    if (location.search){
    ThisPic=location.search.substring(1)*1;
    }else{
    ThisPic=0;
    }

    NextPic=ThisPic+1;ShowNext=(NextPic>(Picture.length-1)?false:true);
    PrevPic=ThisPic-1;ShowPrev=(PrevPic<0?false:true);

    if (ShowPrev){
    document.writeln('<a href="javascript:GotoPic(PrevPic)"><img src="navigation/previous.jpg" width="75" height="23" border="0"></a><img src="navigation/blank.jpg"> ');
    }
    if (ShowNext){
    document.writeln('<a href="javascript:GotoPic(NextPic)"><img src="navigation/next.jpg" width="37" height="23" border="0"></a> ');
    }
    document.write('</P><img src="'+Picture[ThisPic]+'">');
    // -</script>

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Let's clean up your code. Try:
    Code:
    <script type="text/javascript">
    function GotoPic(Num){
      return location.pathname + '?' + Num;
    }
    
    var Picture = new Array;
    Picture.push("imagename.jpg");
    Picture.push("imagename2.jpg");
    Picture.push("imagename3.jpg");
    Picture.push("imagename4.jpg");
    
    var ThisPic,
      PrevPic,
      NextPic,
      ShowPrev,
      ShowNext;
    
    if (location.search)
      ThisPic = location.search.substring(1) * 1;
    else
      ThisPic = 0;
    
    NextPic = ThisPic + 1;
    ShowNext = NextPic > (Picture.length - 1);
    
    PrevPic = ThisPic - 1;
    ShowPrev = PrevPic < 0;
    
    if (ShowPrev)
      document.writeln('<a href="javascript:GotoPic(PrevPic);"><img src="navigation/previous.jpg" width="75" height="23" border="0"></a><img src="navigation/blank.jpg"> ');
    
    if (ShowNext)
      document.writeln('<a href="javascript:GotoPic(NextPic)"><img src="navigation/next.jpg" width="37" height="23" border="0"></a> ');
    
    document.write('</P><img src="'+Picture[ThisPic]+'">');
    
    </script>
    I haven't made any major changes here, just cleaned up your code a little to avoid some bad practices. However, the route you've taken to accomplish this slideshow is a rather circuitous and clunky one. Is there any particular reason you've done it this way, or may I clean up your method as well?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you for your reply.

    I tested your version (on PC/FireFox) but could not get it to work (also still does not display using IE/MAC). The 1st image displays the 'previous' option but not the 'next option'.

    I found the orginal script after asking on various forums for something suited to my needs. I do not really know JavaScript.

    I will Private Msg you the actual site running this script if you feel it would help?

    Many thanks! :-)

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It would, yes. I will need you to test it with IE/Mac, though, since I do not have any version of IE at my disposal.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    A live version of the site can be found here (in case this helps):

    edited-

    And here is a page (one of many) using the script itself:

    -edited--
    Last edited by mejust; 05-17-2006 at 03:22 PM.

  6. #6
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Feel free to change the method :-)
    Really appreciate your help - havent had any responses from various other forums... so a bit stuck now!

  7. #7
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This issue has now been resolved...

    http://forums.htmlcenter.com/showthread.php?p=9946

    Thanks for all your help.

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
  •