Good afternoon everyone, I've managed to write a script that calculates the width and height of an image and properly placed a string of text on the bottom right side of an image for usage with credits/captions.
I've managed to get it to generate, calculate and display perfectly in all browsers other than IE8. For some reason, it is blowing off the screen in IE8 and I can't seem to figure out why it is doing it and improve my JavaScript to possibly have conditional functions for calculations when using IE8.
Any advice?
http://jsfiddle.net/jodriscoll/u26vZ/
$(function ($) {
// jQuery is passed as the first arg $
$('.img-right img,.img-left img').bind('load', function () {
var $img = $(this),
imgHeight = $img.height(),
imgWidth = $img.width();
$img.siblings('p').width(imgWidth);
$img.siblings('span').width(imgHeight);
$img.siblings('.credit').css({
left: imgWidth + 6,
top: imgHeight - 10
});
}).each(function () {
// we need to force the "load" event to fire if it was already complete:
// technique taken from https://gist.github.com/268257
if (this.complete || this.complete === undefined) {
var src = this.src;
// webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
// data uri bypasses webkit log warning
this.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
this.src = src;
}
});
});