works in ie but not mozilla

wxdqz

New Member
thanks to dave clark the following script works, but my one last problem with it is it doesnt work in mozilla. i thought it was because of the way regular expressions were used, but i tried a version using string.replace looking exactly as devedge has it and still it didnt work in mozilla.


// GLOBAL variables


// directory+file file type
REGEX1 = /(.*\/\w*)(\.(?:jpg|png|gif))/i ;
// directory+file 'v' file type
REGEX2 = /(.*\/\w*)v(\.(?:jpg|png|gif))/i ;

// ------------------------------------
// Functions


function Addevents( ) {
for ( var iterator = 0; iterator < document.images.length; iterator++ ) {
if ( document.images[iterator].className === 'navlinkimage' ) {
document.images[iterator].addEventListener( 'mouseover', new Function( 'return Navlinkimagebubble( ' + iterator + ' ) ;' ), false ) ;
document.images[iterator].addEventListener( 'mouseout', new Function( 'return Unnavlinkimagebubble( ' + iterator + ' ) ;' ), false ) ;
}
}
}

function Attachevents( ) {
for ( var iterator = 0; iterator < document.images.length; iterator++ ) {
if ( document.images[iterator].className === 'navlinkimage' ) {
document.images[iterator].attachEvent( 'onmouseover', new Function( 'return Navlinkimagebubble( ' + iterator + ' ) ;' ) ) ;
document.images[iterator].attachEvent( 'onmouseout', new Function( 'return Unnavlinkimagebubble( ' + iterator + ' ) ;' ) ) ;
}
}
}

function Navlinkimagebubble( iterator ) {
document.images[iterator].src = document.images[iterator].src.replace( REGEX1, '$1v$2' ) ;
}

function Unnavlinkimagebubble( iterator ) {
document.images[iterator].src = document.images[iterator].src.replace( REGEX2, '$1$2' ) ;
}


// ------------------------------------
// initialisation


if ( document.addEventListener ) {
window.addEventListener( 'load', Addevents, false ) ;
}
else if ( document.attachEvent ) {
window.attachEvent( 'onload', Attachevents ) ;
}
 
Back
Top