Array slideshow problem

R

Rabel

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

<script type="text/javascript">

var photos=new Array()
var which=0

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


var preloadedimages=new Array()
for (i=0;i<photos.length;i++){
preloadedimages=new Image()
preloadedimages.src=photos
}

function applyeffect(){
if (document.all && photoslider.filters){
photoslider.filters.revealTrans.Transition=Math.floor(Math.random()*23)
photoslider.filters.revealTrans.stop()
}
}

function playeffect(){
if (document.all && photoslider.filters)
photoslider.filters.revealTrans.play()
}

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


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

function forward(){
if (which<photos.length-1){
which++
applyeffect()
document.images.photoslider.src=photos[which]
playeffect()
keeptrack()
}
}

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

</script>

then using this
<script>
if (linkornot==1)
document.write('<a href="javascript:transport()">')
document.write('<img src="'+photos[0]+'" name="photoslider"
style="filter:revealTrans(duration=2,transition=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.
 
I

IBRAYEM

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.
 
R

Random

Rabel said:
Hi I am new to javascript and I am using a code that brings up
pictures(slideshow)
....

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.



'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.referrer 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?showpicture=thatone'),
and your page can parse this informaiton out of location.query
 
R

Rabel

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(projectdetails), 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?
 
R

Random

Rabel said:
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(projectdetails), but there is multiple pictures you could choose
The link can use a GET-type query-string
(i.e. 'mypage.html?showpicture=thato­ne'),
and your page can parse this informaiton out of location.query

I should have written 'location.search'

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.
 
R

Rabel

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

Random

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

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.length ) 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(nameval[0]), unescape(nameval[1]) ];
pgr[ pgr[ c ][ 0 ] ] = pgr[ c ][ 1 ];
}

return pgr;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top