I wrote a jQuery script that works correctly in Opera and Firefox, but Internet Explorer has a problem.
When I start testing the script its return correct text with alert ( prlvg.attr('prl') ); in Opera and Firefox, but in Explorer it returns undefined
The previous steps where I get prlvg is there:
var top = $('a[prl]:first').offset().top;
var vwtmbs = $('a[prl]').filter(function(){
var offsetW = $(this).offset().top - $(window).scrollTop();
return(offsetW <= window.innerHeight );
});
prlvg = vwtmbs.last();
alert ( prlvg.attr('prl') );
How to fix the problem? thanks.
UPDATED: seems problem at window.innerHeight its is undefined at IE and all code after that is also undefined.
Internet Explorer, 7 through 10, is handling your custom attribute just fine: http://jsfiddle.net/xpjcU/.
Aside from that, I would steer away from using custom attributes like this in your HTML. Instead, use the
data-attributes if you want to store extra information about your elements:You can then interact with thsi custom data via
$.data().