SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help with JavaScript picture slideshow

    I am trying to use this JavaScript slideshow code on my website:
    http://www.javascriptkit.com/script/...entslide.shtml

    I have copied the code to my website but it is not cycling through the pictures. Can you suggest what I'm doing wrong? My website address is:
    http://www.grandviewsda.com/Ministry-news

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just noticed a few things....

    This rogue piece of html comment tag in the JavaScript needs removing (and another at the script end):

    Code:
    <script type="text/javascript"><!--
    <!
    Also, there are two parallel arrays being used (they are using the same incrementer variable):

    Code:
    src = ["/site_data/781/assets/0009/6785/abraham-lincoln-625_small.jpg", "/site_data/781/assets/0009/6790/cool_fractal_small.jpg"]
    url = ["http://www.Grandviewsda.com"]
    The src[] array here has 2 elements; the url[] array has just one. They must have the same number of elements, else there will be an error.

    Also, note that the following line in the original script will work in Internet Explorer, which allows the status bar to show the current url here. But many other browsers don't allow writing to the status bar. It's not causing a fatal error here; the other non-IE browsers are just going to ignore this part:

    Code:
    <a onmouseover="status=url[ct];return true;"

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay I implemented some of the changes you suggested, but I'm still confused about about what you're saying regarding the arrays. You said I am using two parallel arrays with the same incrementer variable. I don't know anything about JavaScript, so I have no idea what that means. Is that something that needs to be fixed, and how do I do that?

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'll just need to add another url to the url array. Every time it changes the image, it also changes the url and, for IE only, displays that url on the status bar. At the moment, it has 2 elements to swap in the src array, but only the one element in the url array.

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have made those changes to the URL array, but it is still not working.

  6. #6
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is a jquery based slideshow demo. All you need to do is provide an array with image source data and an image tag which will be turned in to a slideshow by the plugin. Feel free to post any questions you may have.

    http://dfizz.com/jquery_slideshow/

  7. #7
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A problem here:

    Code:
    onload = function(){
     if (document.images)switchAd();
    )
    Change that to:

    Code:
    window.onload = function(){
     if (document.images) switchAd();
    }
    You'll need to put CDATA tags around your JavaScript, as you are using xhtml. And there are some deprecated attributes e.g. <p align="center">, so swap to a Transitional xhtml doctype, not a strict one.

    I checked previously and again with a stripped down version of your site and this image swap script does work, with the afore-mentioned status bar limitation. If it's not working now, I would bet there is a conflict somewhere with those 8 other JavaScript files.

  8. #8
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I fixed the issue with the code that you mentioned. I'm not sure what I'm supposed to do with the CDATA tags. I was reading here:
    http://www.w3schools.com/xmL/xml_cdata.asp

    I added the CDATA tags just as they showed on that page. Despite those two changes the slideshow is still not working.

    Regarding the XHTML doctype and the other JavaScript files, I do not have the ability to modify them. We are using a very specialized service for our website, and they have placed significant limits on the technical details I can modify. I could ask them if they could make changes like you have suggested, but they are managing thousands of websites using the same basic platform so I'm not sure that they would. Is there a better way of doing this?

  9. #9
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,869
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    You don't need the CDATA tag unless you are really using XHTML (as determined by the MIME type and not by the doctype).

    Since most JavaScript that works for HTML will not work for XHTML without a fair amount of modification you don't need to worry about CDATA at all unless you really are planning to use XHTML (in which case any code for Internet Explorer becomes irrelevant as it doesn't support XHTML at all).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  10. #10
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem does seem likely to be a clash with another of the scripts present on the page, assuming the image file paths are correct. I have tested the page locally on 2 separate occasions, minus all those externally referenced scripts & stylesheets, and with my own images, and it certainly works. Even with that wrong doctype, it still works, not that a couple of deprecated attributes on another part of the page will make a difference. You may have more luck trying a different image-changing script. Unfortunately, the clashing of scripts does occur from time to time.


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
  •