...

View Full Version : target="main" in javascript



allyson
07-22-2002, 05:21 AM
Hi

I am trying to make a slideshow in a framed page, and want the images to appear in the main frame. In the functions below, the images are displayed. How can I alter them, so that the images are displayed in the main target frame.

function backward(){
if (which>0){
window.status=''
which--
document.images.photoslider.src=photos[which]
}
}

function forward(){
if (which<photos.length-1){
which++
document.images.photoslider.src=photos[which]
}
else window.status='End of gallery'
}

bye
Allyson

Cloudski
07-22-2002, 05:34 AM
I am not sure that this will work, but try:

main.document.images.photoslider.src=photos[which]


Of course then again, this may not be the correct spot for the modifying... *sigh* This area of Javascript is new to me...

allyson
07-22-2002, 09:30 AM
Thanks for this suggestion, but it isn't working. I tried moving main just before .src, still doesn't work.

Can anyone help, please.

bye
Allyson:D

Gordo
07-22-2002, 09:44 AM
Personally, I'd need to see your test (framed) page before giving any "quality" response. So, give us a link if you want/need more replies.

glenngv
07-22-2002, 10:33 AM
top.main.document.images.photoslider.src=photos[which]

or

top.frames["main"].document.images.photoslider.src=photos[which]

of course in your main frame, you should have:

<img name="photoslider">

Cloudski
07-22-2002, 10:39 AM
I was close :D

allyson
07-23-2002, 07:11 AM
Hi

Thank-you all for your suggestions. The function works well.

This function is a framed slideshow, http://homepages.ihug.co.nz/~usateden/panacea/slideshow

I would like to modify it so that as the user is viewing the first slide, the second slide is being preloaded, so that the transition between slides is fast.

Any suggestions on how modify the script would be very much appreciated.

<html>

<head>
<title>Panacea Arts Trust</title>
</head>

<body background="../images/bg1.jpg">

<table border="0" cellpadding="0">
<tr>
<td width="100%"><form method="POST" name="rotater">
<div align="center"><center><p><script language="JavaScript">
var photos=new Array()
var text=new Array()
var which=0
var what=0

/*Images */
photos[0]="../Cards/Busy%20Lizzies.jpg"
photos[1]="../Cards/Flowers for Elizabeth.jpg"
photos[2]="../Cards/Potters Park.jpg"
photos[3]="../Cards/Racing Yachts.jpg"
photos[4]="../Cards/Nana Mouskouri.jpg"

/*Descriptions*/
text[0]="Busy Lizzies"
text[1]="Flowers for Elizabth"
text[2]="Potters Park"
text[3]="Racing Yachts"
text[4]="Nana Mouskouri"

top.frames["description"].document.rotater.description.value=text[0];


function backward(){
if (which>0){

window.status=''
which--
top.frames["main"].document.images.photoslider.src=photos[which] ;
what--
top.frames["description"].document.rotater.description.value=text[what];
}
}

function forward(){
if (which<photos.length-1){

which++
top.frames["main"].document.images.photoslider.src=photos[which] ;
what++
top.frames["description"].document.rotater.description.value=text[what];
}
else window.status='End of gallery'
}

glenngv
07-25-2002, 05:42 AM
/*Images */
photos[0]="../Cards/Busy%20Lizzies.jpg"
photos[1]="../Cards/Flowers for Elizabeth.jpg"
photos[2]="../Cards/Potters Park.jpg"
photos[3]="../Cards/Racing Yachts.jpg"
photos[4]="../Cards/Nana Mouskouri.jpg"

function preloadImages(){
//load first slide
top.frames["main"].document.images.photoslider.src=photos[0];

//pre-load other slides
for (var i=1;i<photos.length;i++){
image = new Image(photos[i]);
}
}

window.onload=preloadImages;

allyson
07-25-2002, 11:51 AM
Hi

Thankyou very much for your advice. It's been great.

One more problem, though. Take a look at http://homepages.ihug.co.nz/~usateden/panacea/slideshow/index.html

When you first go into the site, everything works as it should except there is no text in the box. As the next slide shows, the textbox works, and when you click "Start Over" the first image appears, along with the appropriate text.

The first print statement '
top.frames["description"].document.rotater.description.value=text[0];

appears not to work, when the webpage starts. I don't know why. Any advice. Thank-you

bye
Allyson

glenngv
07-26-2002, 03:27 AM
put it also in the onload function. One word of advice, if you are putting initial values on elements on page load using javascript, you should do it once the page has completely loaded, that is, you do it on onload event. What you were doing was, you put initial value to the description textbox that has not yet loaded.

/*Images */
photos[0]="../Cards/Busy%20Lizzies.jpg"
photos[1]="../Cards/Flowers for Elizabeth.jpg"
photos[2]="../Cards/Potters Park.jpg"
photos[3]="../Cards/Racing Yachts.jpg"
photos[4]="../Cards/Nana Mouskouri.jpg"

function preloadImages(){
//load first slide
top.frames["main"].document.images.photoslider.src=photos[0];
top.frames["description"].document.rotater.description.value=text[0];


//pre-load other slides
for (var i=1;i<photos.length;i++){
image = new Image(photos[i]);
}
}

window.onload=preloadImages;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum