View Full Version : Simple Gallery problem with navigate

05-09-2012, 06:54 PM
1) Script Title:
//** Simple Controls Gallery- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com
//** Dec 7th, 08'- Script created
//** February 6th, 09'- Updated to v 1.3:

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/simplegallery.htm

3) Describe problem:

Hello everyone!

The script it's working but I can't navigate <a href="javascript:mygallery.navigate('prev')"> don't responde and I don't know how to solve it.

Hope you can help me, thanks in advance!


foreach($banners as $ban){
//$img['titulo'][] = "titulo ".$ban->titulo;
$img['link'][] = "http://".$ban->link."/";


<script type="text/javascript">
window.onload = function(){

var img = new Array();
var imagenes = <?=json_encode($img)?>


// img[i] = new Array( imagenes['img'][i],imagenes['link'][i],"_new",imagenes['titulo'][i] );
img[i] = new Array( imagenes['img'][i],imagenes['link'][i] );


var mygallery=new simpleGallery({
wrapperid: "simplegallery", //ID of main gallery container,
dimensions: [1280, 510], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
autoplay: [true, 4000, 200], //[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
oninit:function(){ //event that fires when gallery has initialized/ ready to run
//Keyword "this": references current gallery instance (ie: try this.navigate("play/pause"))

onslide:function(curslide, i){ //event that fires after each slide is shown
//Keyword "this": references current gallery instance
//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)


<div class="banner">
<div style="float:left;margin-left:-150px">
<div id="simplegallery"></div>
<div class="mascara"> <a href="javascript:mygallery.navigate('prev')"><img src="images/left.png" /></a><a href="javascript:mygallery.navigate('next')"><img src="images/right.png" style="margin-left:867px"/></a></div>

05-10-2012, 02:02 PM
Variables in the window.onload function are outside the global scope, so mygallery is undefined in the navigation links.


var mygallery=new simpleGallery({


window.mygallery=new simpleGallery({

The browser cache may need to be cleared and/or the page refreshed to see changes.

If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.