Helpful Information
 
 
Category: Dynamic Drive scripts help
How to keep slide show within frames

I have used a slide show script on my main page which is framed. The slides are linked to urls within the site but when I click on the slides they go straight out of the frame.

Here is the relevant code;
<a href="javascript:gotoshow()" target="_top"><img src="/portal/html/thumbs/accountants2.gif" name="slide" border=0 width=88 height=100></a>
<script>
<!--

//configure the paths of the images, plus corresponding target links
slideshowimages("thumbs/accountants2.gif","thumbs/electricians2.gif","thumbs/alternative2.gif","thumbs/wedding2.gif","thumbs/rubbish2.gif")
slideshowlinks("http://www.crawleyontheweb.com/businessdirectory/ads.cgi?ct=Accountants&md","http://www.crawleyontheweb.com/businessdirectory/ads.cgi?ct=Electricians&md","http://www.crawleyontheweb.com/businessdirectory/ads.cgi?ct=Alternative&md","http://www.crawleyontheweb.com/businessdirectory/ads.cgi?ct=Wedding_Services&md","http://www.crawleyontheweb.com/businessdirectory/ads.cgi?ct=Rubbish_Removal&md")

Is there anything I can do to keep it within the frames?

<a href="javascript:gotoshow()" target="_top">

delete that bit in bold.

Sorry I only put that there so it would stop the frame breaking when someone clicked on the image. When I remove it and someone clicks it goes straight out of the frame - with target =top absolutely nothing happens -

Any more suggestions?

well, hold on a minute. what exactly do you mean, by "going out of the frame" ? do you mean a new window is opening, or what is it that you mean?

also, i think we definitely need to see the rest of your code, to figure out what's going on.

yes you are right its opening a new page without the frame.

Which bit of the code do you want ? that particular javascript?

Heres the whole thing.
<!--Special Effects upon page enter Script- © Dynamic Drive (www.dynamicdrive.com) For full source code, installation instructions, 100's more DHTML Scripts, and Terms Of Use, visit dynamicdrive.com--><META http-equiv="Page-Enter" CONTENT="RevealTrans(Duration=4,Transition=3)">
<script language="JavaScript1.1">

<!--



var slideimages=new Array()
var slidelinks=new Array()
function slideshowimages(){
for (i=0;i<slideshowimages.arguments.length;i++){
slideimages[i]=new Image()
slideimages[i].src=slideshowimages.arguments[i]
}
}

function slideshowlinks(){
for (i=0;i<slideshowlinks.arguments.length;i++)
slidelinks[i]=slideshowlinks.arguments[i]
}

function gotoshow(){
if (!window.winslide||winslide.closed)
winslide=window.open(slidelinks[whichlink])
else
winslide.location=slidelinks[whichlink]
winslide.focus()
}

//-->
</script>

<a href="javascript:gotoshow()"><img src="/portal/html/thumbs/accountants2.gif" name="slide" border=0 width=88 height=100></a>
<script>
<!--

//configure the paths of the images, plus corresponding target links
slideshowimages("thumbs/accountants2.gif","thumbs/electricians2.gif","thumbs/alternative2.gif","thumbs/wedding2.gif","thumbs/rubbish2.gif")
slideshowlinks("/businessdirectory/ads.cgi?ct=Accountants&md","http://www.crawleyontheweb.com/businessdirectory/ads.cgi?ct=Electricians&md","http://www.crawleyontheweb.com/businessdirectory/ads.cgi?ct=Alternative&md","http://www.crawleyontheweb.com/businessdirectory/ads.cgi?ct=Wedding_Services&md","http://www.crawleyontheweb.com/businessdirectory/ads.cgi?ct=Rubbish_Removal&md")

//configure the speed of the slideshow, in miliseconds
var slideshowspeed=3500

var whichlink=0
var whichimage=0
function slideit(){
if (!document.images)
return
document.images.slide.src=slideimages[whichimage].src
whichlink=whichimage
if (whichimage<slideimages.length-1)
whichimage++
else
whichimage=0
setTimeout("slideit()",slideshowspeed)
}
slideit()

//-->
</script>

If you go to http://www.crawleyontheweb.com and scroll down to the bottom in the bottom right hand box under 'health' there is 'test' click on this and this page only contains the above code and you can see the new page opening.

function gotoshow(){
if (!window.winslide||winslide.closed)
winslide=window.open(slidelinks[whichlink])
else
winslide.location=slidelinks[whichlink]
winslide.focus()
}

there's your problem.

try this instead:

function gotoshow(){
window.location=slidelinks[whichlink];
}

this is the code now
<script language="JavaScript1.1">

<!--



var slideimages=new Array()
var slidelinks=new Array()
function slideshowimages(){
for (i=0;i<slideshowimages.arguments.length;i++){
slideimages[i]=new Image()
slideimages[i].src=slideshowimages.arguments[i]
}
}

function slideshowlinks(){
for (i=0;i<slideshowlinks.arguments.length;i++)
slidelinks[i]=slideshowlinks.arguments[i]
}

function gotoshow(){ window.location=slidelinks[whichlink];
}

else
winslide.location=slidelinks[whichlink]
winslide.focus()
}

//-->
</script>

Try it - it just errors now. - should I have removed the 'else' statement?

yes

Thanks so much - I have learnt something from this.










privacy (GDPR)