Too much recursion 

Higher Order Javascript


   Subscribe in NewsGator Online    Subscribe in Rojo    Add to Google      Add to My AOL   Subscribe in FeedLounge   Add to netvibes  

Brendan Eich's Roadmap  Standard ECMA-262  Yahoo! UI Library     

Saturday, September 23, 2006


IE 5.5 IE6.x Transparent PNG fix + Mimified Brothercake Browser Detect

IE png fix. Works well. Included with a condensed/optimized version of Brothercake's Browser Detection Script. Read comments for use with or without browser detection.

// minified Brothercake browser detection object (thanks bro!)
// usage: alert(Browser.browser+'\n'+Browser.version+'\n'+Browser.OS)
var Browser = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion) || "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
searchString: function (data) {
for (var i=0,len=data.length;i var dataString = data[i].string, dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if((dataString) && (dataString.indexOf(data[i].subString) != -1)||(dataProp)){
return data[i].identity
} } },
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString); if (index == -1) return;
return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
dataBrowser: [
{string: navigator.vendor, subString: "Apple", identity: "Safari"},
{prop: window.opera,identity: "Opera"},
{string: navigator.vendor, subString: "iCab", identity: "iCab"},
{string: navigator.vendor, subString: "KDE", identity: "Konqueror"},
{string: navigator.userAgent,subString: "Firefox", identity: "Firefox"},
{string: navigator.userAgent,subString: "Netscape",identity: "Netscape"},// for newer Netscapes (6+)
{string: navigator.userAgent,subString: "MSIE", identity: "IE", versionSearch: "MSIE"},
{string: navigator.userAgent,subString: "Gecko", identity: "Mozilla", versionSearch: "rv"},
{string: navigator.userAgent,subString: "Mozilla", identity: "Netscape",versionSearch: "Mozilla"}],// for older Netscapes (4-)
dataOS : [
{string: navigator.platform, subString: "Win", identity: "Windows"},
{string: navigator.platform, subString: "Mac", identity: "Mac" },
{string: navigator.platform, subString: "Linux", identity: "Linux" }]

// IE PNG FIX: correctly handle PNG transparency in Win IE 5.5 > 6.x
if((Browser.version>5.4) && (Browser.version<7) && (Browser.browser=='IE')){
// uncomment line below and comment line above to become independent of browser detect script
//if(window.attachEvent && (parseFloat(navigator.appVersion.split("MSIE")[1])<7)){
window.attachEvent("onload",function(){ if (document.body.filters){
var i=document.images.length; while(i--){
var img = document.images[i], imgName = img.src.toUpperCase();
if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){ var
imgID = ( ? "id='" + + "' " : "",
imgClass = (img.className) ? "class='" + img.className + "' " : "",
imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ",
imgStyle = "display:inline-block;" +;
if (img.align == "left") image.align='left'; //imgStyle = "float:left;" + imgStyle
if (img.align == "right")image.align='left'; //imgStyle = "float:right;"+ imgStyle
if (img.parentElement.href) imgStyle = "cursor:pointer;" + imgStyle
img.outerHTML= " + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\">
} } } } ) };

// this script correctly handle PNG transparency in Win IE 5.5 or higher.
// BUT the image mapping not work with!
I could be wrong, but I believe the above is missing an object directly after the assignment to the .outerHTML element. After trying to use the script I noticed I had to include a span element myself, as well as the imgID not even being printed out. If you're having issues with the above code this is probably why, notice how the imgID string and the imgTitle aren't even used in the printout to outerHTML.


Despite the described problem, I *can* say that this code saved my life.. totally appreciate the contribution
Thanks, did this real fast, post the corrected script please.
buy viagra
generic viagra
buy viagra
generic viagra
Interesting article, added his blog to Favorites
This is really fantastic work friend..The Way in which You represent this blog is awesome.I really appreciate your work. Keep it up in future.
Post a Comment

Links to this post:

Create a Link

<< Home


June 2006   July 2006   August 2006   September 2006  

This page is powered by Blogger. Isn't yours?