/    Sign up×
Community /Pin to ProfileBookmark

PNGFIX Not Working with Another Script

I have an issue with the IE6 png fix not working with the tab js.

Here’s the test page: doo rshox.com/tab-p ages.html (remove spaces)

I think it has something to do with the onload function but then I don’t know js well enough to troubleshoot issues like these.

Here’s the pngfix script code:

[code]var supersleight = function() {

var root = false;
var applyPositioning = true;

// Path to a transparent GIF image
var shim = ‘door-protector/pc/scripts/pngfix/x.gif’;

// RegExp to match above GIF image name
var shim_pattern = /x.gif$/i;

var fnLoadPngs = function() {
if (root) {
root = document.getElementById(root);
}else{
root = document;
}
for (var i = root.all.length – 1, obj = null; (obj = root.all[i]); i–) {
// background pngs
if (obj.currentStyle.backgroundImage.match(/.png/i) !== null) {
bg_fnFixPng(obj);
}
// image elements
if (obj.tagName==’IMG’ && obj.src.match(/.png$/i) !== null){
el_fnFixPng(obj);
}
// apply position to ‘active’ elements
if (applyPositioning && (obj.tagName==’A’ || obj.tagName==’INPUT’) && obj.style.position === ”){
obj.style.position = ‘relative’;
}
}
};

var bg_fnFixPng = function(obj) {
var mode = ‘scale’;
var bg = obj.currentStyle.backgroundImage;
var src = bg.substring(5,bg.length-2);
if (obj.currentStyle.backgroundRepeat == ‘no-repeat’) {
mode = ‘crop’;
}
obj.style.filter = “progid:DXImageTransform.Microsoft.AlphaImageLoader(src='” + src + “‘, sizingMethod='” + mode + “‘)”;
obj.style.backgroundImage = ‘url(‘+shim+’)’;
};

var el_fnFixPng = function(img) {
var src = img.src;
img.style.width = img.width + “px”;
img.style.height = img.height + “px”;
img.style.filter = “progid:DXImageTransform.Microsoft.AlphaImageLoader(src='” + src + “‘, sizingMethod=’scale’)”;
img.src = shim;
};

var addLoadEvent = function(func) {
var oldonload = window.onload;
if (typeof window.onload != ‘function’) {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
};
}
};

return {
init: function() {
addLoadEvent(fnLoadPngs);
},

limitTo: function(el) {
root = el;
},

run: function() {
fnLoadPngs();
}
};
}();

// limit to part of the page … pass an ID to limitTo:
// supersleight.limitTo(‘header’);

supersleight.init();[/code]

Here’s the tab script code:

[code]
onload = function() {
var e, i = 0;
while (e = document.getElementById(‘tab-1’).getElementsByTagName (‘DIV’) [i++]) {
if (e.className == ‘on’ || e.className == ‘off’) {
e.onclick = function () {
var getEls = document.getElementsByTagName(‘DIV’);
for (var z=0; z<getEls.length; z++) {
getEls[z].className=getEls[z].className.replace(‘show’, ‘hide’);
getEls[z].className=getEls[z].className.replace(‘on’, ‘off’);
}
this.className = ‘on’;
var max = this.getAttribute(‘title’);
document.getElementById(max).className = “show”;
}
}
}
}
[/code]

I can’t recall where I got the pngfix but the other script is from stu nicholls.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorJun 12.2009 — have you considered a CSS solution like:

http://www.webdeveloper.com/forum/showthread.php?t=209584

?
Copy linkTweet thisAlerts:
@newseedauthorJun 12.2009 — have you considered a CSS solution like:

http://www.webdeveloper.com/forum/showthread.php?t=209584

?[/QUOTE]

I haven't really but after reading the post I don't think this will be ideal for me because I have several images ebmedded into the html.
×

Success!

Help @newseed spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...