hi all, this code is for a picture viewer. yes, this is my first code
and my first piece of programming so i maybe simply be missing some key
notions here. the problem is: the nav onclick event buttons to flip
through the pics only work in IE and not in FF, i havnt tested anywhere
else. I have tried lots of thing such as including the code directly
after the event or in the headleft and headright functions, replacing
the event function by a simple alert(); **onclick = function () {
alert('there'); }**, or assigning the events after their elements have
been inserted into DOM,...the bastard simply doesnt recognise the
event although i assign the top nav bar events the same way. The page
can be found at http://max.nugraphic.com/ajax/aixaqua/ o know it still
looks ugly especially in IE but I havnt gotten to the design yet.
thank you so much, im losing patience
photo.js:
function createphotobox( ) {
var contentdiv = document.getEle mentById('conte nt');
var photobox = document.create Element('div'); //pic-img tag
container
photobox.id = "photobox";
contentdiv.appe ndChild(photobo x);
addphoto(photob ox); //pic-img tag into designated container
addnav(contentd iv); //nav underneath pic conatiner above
}
function addphoto(el) { // lay pic
var pic = document.create Element('img');
pic.src = phppaths[0]; //fine array imported from php
pic.num = 0; //temporary pic index system..
pic.id = "pic";
pic.width = "480";
el.appendChild( pic);
}
function addnav(el) { //Add 2 nav items under
pic
var nav = document.create Element('div');
nav.id = "photonav";
var navleft = document.create Element('img');
var navright = document.create Element('img');
navleft.src = "images/photonav_left.g if";
navright.src = "images/photonav_right. gif";
navleft.onclick = headleft; //<<<problemati c
events
navright.onclic k = headright;
el.appendChild( nav);
nav.appendChild (navleft);
nav.appendChild (navright);
}
function headleft(event) {
currentpic('lef t');
return false;
}
function headright(event ) {
currentpic('rig ht');
return false;
}
function currentpic(dire ction) {
var dir = direction;
var pic = document.getEle mentById('pic') ;
var a = pic.num;
switch(dir) {
case 'right':
pic.src = phppaths[a+1];
pic.num++;
break;
case 'left':
pic.src = phppaths[a-1];
pic.num--;
break;
default:
break;
}
}