Forum Moderators: open

Message Too Old, No Replies

Object problems in IE

Browser problems with JS

         

Kings on steeds

2:03 am on Feb 18, 2009 (gmt 0)

10+ Year Member



Please help me, i have written a little script to unobtrisily load a gallery, it all works fine in FF but fails in ie and as i am not using a fall back for javascript browsers it's just leaving an empty page... :-(


var gallery = {
lines: [],
container: "galleryImages",
imageHolder: "galleryimage",
captionHolder: "galleryCaption",
currentLine: 0,
currentImage: 0,
loadLines: function(){
var res = $A($(gallery.container).getElementsByTagName('div')).each(function(s, index){
if(s.hasAttribute('galline')){
var temp = {no: "", id: "", imgs: ""}
temp.no = index;
temp.id = s.id
temp.imgs = $A(s.getElementsByTagName('img'));
gallery.lines.push(temp);
}
});
},
load: function(){
// Load lines
gallery.loadLines();
// Show first
$(gallery.lines[0].id).show();
gallery.currentLine = gallery.lines[0].no;
//get first image to show.
gallery.putImage(gallery.getImageDetails($(gallery.lines[0].imgs[0].id)));
},
nextLine: function(){
var next = gallery.currentLine + 1;
if(next >= gallery.lines.length){
alert('Sorry, there are no more sets to view');
} else {
$(gallery.lines[gallery.currentLine].id).hide();
$(gallery.lines[next].id).show();
gallery.currentLine = next;
}
},
previousLine: function(){
var prev = gallery.currentLine - 1;
if(prev < 0){
alert('Sorry, there are no more sets to view');
} else {
$(gallery.lines[gallery.currentLine].id).hide();
$(gallery.lines[prev].id).show();
gallery.currentLine = prev;
}
},
putImage: function(g){
$(gallery.imageHolder).innerHTML = "<img src='"+g.image+"' style='width: 100%;height: 100%;'>";
$(gallery.captionHolder).innerHTML = g.caption;
gallery.currentImage = g.id;
},
getImageDetails: function(idx){
var ele = $(idx);
var cap = ele.readAttribute('alt');
var src = ele.readAttribute('src');
var iTemp = {idx: idx, image: src, caption: cap}
return iTemp;
},
showImage: function(idx){
gallery.putImage(gallery.getImageDetails('img'+idx));
}
}

IE just tells me,

Line: 12
Char: 4
Error: Object doesn't support this property or method
Code: 0

please can someone save my life and tell me what the hell is going wrong?

FYI, i am using prototype 1.5.1

daveVk

2:45 am on Feb 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if(s.hasAttribute('galline'))

IE does not support hasAttribute, workaround is to getAttribute and check for null or "", google for "IE hasAttribute" for details.

Kings on steeds

2:58 am on Feb 18, 2009 (gmt 0)

10+ Year Member



DOH! it says that in the prototype docs i am such a dofus! thanks you! life saver!

sirnoucamp

9:18 am on Mar 3, 2009 (gmt 0)

10+ Year Member



is there anyway we can debug with Javascript?
without printscreen everything?