Array slideshow problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rabel

    #1

    Array slideshow problem

    Hi I am new to javascript and I am using a code that brings up
    pictures(slides how) with this code

    <script type="text/javascript">

    var photos=new Array()
    var which=0

    photos[0]="../images/fullfc_pe_04.jp g"
    photos[1]="../images/fullfc_pe_05.jp g"
    photos[2]="../images/fullfc_pe_06.jp g"
    photos[3]="../images/fullfc_pe_07.jp g"
    photos[4]="../images/fullfc_pe_08.jp g"
    photos[5]="../images/fullfc_pe_09.jp g"
    photos[6]="../images/fullfc_pe_12.jp g"


    var preloadedimages =new Array()
    for (i=0;i<photos.l ength;i++){
    preloadedimages[i]=new Image()
    preloadedimages[i].src=photos[i]
    }

    function applyeffect(){
    if (document.all && photoslider.fil ters){
    photoslider.fil ters.revealTran s.Transition=Ma th.floor(Math.r andom()*23)
    photoslider.fil ters.revealTran s.stop()
    }
    }

    function playeffect(){
    if (document.all && photoslider.fil ters)
    photoslider.fil ters.revealTran s.play()
    }

    function keeptrack(){
    window.status=" Image "+(which+1) +" of "+photos.le ngth
    }


    function backward(){
    if (which>0){
    which--
    applyeffect()
    document.images .photoslider.sr c=photos[which]
    playeffect()
    keeptrack()
    }
    }

    function forward(){
    if (which<photos.l ength-1){
    which++
    applyeffect()
    document.images .photoslider.sr c=photos[which]
    playeffect()
    keeptrack()
    }
    }

    function transport(){
    window.location =photoslink[which]
    }

    </script>

    then using this
    <script>
    if (linkornot==1)
    document.write( '<a href="javascrip t:transport()"> ')
    document.write( '<img src="'+photos[0]+'" name="photoslid er"
    style="filter:r evealTrans(dura tion=2,transiti on=23)" border=0>')
    if (linkornot==1)
    document.write( '</a>')
    </script>

    I got that code from a co-worker who got it at a free code site and I
    know some of it isnt used. The question I have is can I tell a link
    from a another page which picture I want it to load, if so how would I
    go about that, thanks in advance.

  • IBRAYEM

    #2
    Re: Array slideshow problem

    you can if you are have persmission to edit the other page which has
    the link. Otherwise you can't make any changes to pages that does not
    belong to you and that link to your page.

    Comment

    • Rabel

      #3
      Re: Array slideshow problem

      Yes this is another page(with the link) in our site

      Comment

      • Random

        #4
        Re: Array slideshow problem

        Rabel wrote:[color=blue]
        > Hi I am new to javascript and I am using a code that brings up
        > pictures(slides how)[/color]

        ....
        [color=blue]
        > I got that code from a co-worker who got it at a free code site and I
        > know some of it isnt used. The question I have is can I tell a link
        > from a another page which picture I want it to load, if so how would I
        > go about that, thanks in advance.[/color]



        'Can I tell a link from another page [what to do?]'

        Not exactly clear what you're after.

        Do you mean changing the picture that's displayed on your page,
        depending on what page linked to it?
        Use document.referr er to find out where they came from.

        Do you mean that you want people to be able to link to your page and
        specify a default image to display?
        The link can use a GET-type query-string
        (i.e. 'mypage.html?sh owpicture=thato ne'),
        and your page can parse this informaiton out of location.query

        Comment

        • Rabel

          #5
          Re: Array slideshow problem

          you had it I would like to add a query string - see now it brings up
          the first picture in the array when you come to the
          page(projectdet ails), but there is multiple pictures you could choose
          on the previous page(project), I need to make it come up with the
          picture you choose on the previous page. any ideas how I would do that?

          Comment

          • Random

            #6
            Re: Array slideshow problem

            Rabel wrote:[color=blue]
            > you had it I would like to add a query string - see now it brings up
            > the first picture in the array when you come to the
            > page(projectdet ails), but there is multiple pictures you could choose
            > on the previous page(project), I need to make it come up with the
            > picture you choose on the previous page. any ideas how I would do that?[/color]

            I wrote:[color=blue]
            > The link can use a GET-type query-string
            > (i.e. 'mypage.html?sh owpicture=thato ­ne'),
            > and your page can parse this informaiton out of location.query[/color]

            I should have written 'location.searc h'

            Parse your page's location.search , using the String.split() method and
            the predefined unescape() function.

            Then you have a method by which the previous (or any other) page can
            tell your page which picture to show.

            Play with it-- you'll find it relatively straightforward , if a little
            tedious.

            Comment

            • Rabel

              #7
              Re: Array slideshow problem

              thanks Random, I am pretty new to javascript any sample code you can
              throw in, thanks again

              Comment

              • Random

                #8
                Re: Array slideshow problem

                Rabel wrote:[color=blue]
                > thanks Random, I am pretty new to javascript any sample code you can
                > throw in, thanks again[/color]

                I generally prefer not to write people's code for them as it usually
                doesn't lead to any real learning or understanding (it's also generally
                a good idea not to ask). Really I recommend researching the ample
                information I included in my previous reply and finding out how to make
                it work best for you. It's a good exercise.

                But a couple of years ago I wrote the following little snippet with the
                intent of writing people's code for them. Bear in mind, I haven't
                revisited it since.

                function parseGet( URL ) {
                var pgs = new Array();
                var nameval = new Array();
                var pgr = new Array();
                if( ! arguments.lengt h ) URL = location.href;

                pgs = URL.split('?');
                if( ! pgs[1] ) return null;
                pgs = pgs[1].split('&');

                for( var c = 0; c < pgs.length; c++ ) {
                nameval = pgs[ c ].split('=');
                pgr[ c ] = [ unescape(nameva l[0]), unescape(nameva l[1]) ];
                pgr[ pgr[ c ][ 0 ] ] = pgr[ c ][ 1 ];
                }

                return pgr;
                }

                Comment

                Working...