Ok, I m stumped. Basically, this script works fine in FF, but not in IE (6,7 or 8) - in which it returns an "Object doesn t support this property or method" error. Any ideas?:
function portfolioAjaxLoader(page){
$("div#portfolio_container").load("include/DCK_portfolio_gallery.inc.php?cat=" + page);
}
$(document).ready(function(){
$( a.portfolio_subnav ).livequery( click ,function(){
portfolioAjaxLoader(this.title);
return false;
});
//modify page DOM if Javascript is switched on
$( div#gallery_frame ).livequery(function(){
//assign portfolioAjaxLoader to sub navigation links
gallery_frame = $( div#gallery_frame );
//set gallery_strip width to the number of entries multiplied by width of gallery entry element
gallery_strip = $( div#gallery_strip );
gallery_entries = $( div#gallery_strip a );
elementWidth = 235;
gallery_strip_width = elementWidth*gallery_entries.length+ px ;
gallery_strip.css({ width :gallery_strip_width});
//add portfolio navigation buttons
if(gallery_entries.length>4){
$( div#portfolio_nav ).before( <p id="portfolio_nav_prev"></p><p id="portfolio_nav_next"></p> );
}
//assign event triggers to inserted portfolio nav elements
prev = $("p#portfolio_nav_prev");
next = $("p#portfolio_nav_next");
scrollPrevMax = (((gallery_entries.length - 4) * elementWidth)+20);//tolerance
scrollMax = ((gallery_entries.length - 5) * elementWidth);
scrollMin = ((gallery_entries.length - 6) * elementWidth);
});
function nextAnim(){
//remove handler
next.unbind();
var currentScrollPos = gallery_frame.scrollLeft();
var targetPos = currentScrollPos + elementWidth;
if(currentScrollPos > scrollMin){
next.fadeOut("fast");
}
if(currentScrollPos >= 0){
prev.fadeIn("fast");
}
gallery_frame.animate({scrollLeft:targetPos}, 300, easeInOutQuart ,function(){next.bind( click ,nextAnim)});
return false;
}
function prevAnim(){
//remove handler
prev.unbind();
var currentScrollPos = gallery_frame.scrollLeft();
var targetPos = currentScrollPos - elementWidth;
if(currentScrollPos < scrollPrevMax){
next.fadeIn("fast");
}
if((currentScrollPos == 0)||(currentScrollPos < elementWidth*2)){
prev.fadeOut("fast");
}
gallery_frame.animate({scrollLeft:targetPos}, 300, easeInOutQuart ,function(){prev.bind( click ,prevAnim)});
//prev.bind( click ,prevAnim);
return false;
}
next.click(nextAnim);
prev.click(prevAnim);
});
I ve purposefully left some elements in the global scope (by omitting var in their declaration).
Just for the record, it reports the error here:
gallery_frame = $( div#gallery_frame );
Character 9, line 16.