|
Post by (¯`•DregondRahl•._) on Jan 5, 2007 17:03:17 GMT
Saw someone wanting a method to fix the transparency problem for rollovers. this one is very basic fix but will work for websites or PB templates.
<script type="text/Javascript"> <!-- // Fix transparency and Rollovers
if (!window.XMLHttpRequest && document.body.filters) {
e = "DXImageTransform.Microsoft.AlphaImageLoader" for(i = 0; i < document.images.length; i ++) { img = document.images if (img.src.match(/(.png|.gif)/i)){ imgUrl = img.getAttribute("src"); img.style.cssText = 'filter:progid:'+ e +'(src=' + imgUrl + ', sizingMethod="scale")'; img.style.height = img.height; img.style.width = img.width; img.setAttribute("src", "http://s4.images.proboards.com/blank.gif"); } if(img.filters[e].src.match(/_o(n|ff)/)) { img.onmouseover = function(){ this.filters[e].src = this.filters[e].src.replace("_off", "_on"); }; img.onmouseout = function() { this.filters[e].src = this.filters[e].src.replace("_on", "_off"); }; } } }
//--> </script>
you have to save the normal image with _off at the end of its name yourhost.com/home_off.pngand the rollover image with _on at the end of its name yourhost.com/home_on.pngthe code will automatically switch the URL from _off to _on when you mouseOver it.
|
|
|
Post by virtuoso on Jan 5, 2007 19:06:45 GMT
Not bad, thought I've seen some other ways, potentially simpler, to conquer the problem. But good job.
|
|
|
Post by (¯`•DregondRahl•._) on Jan 5, 2007 19:39:08 GMT
actually this should be one of the simplest ways of doing it because it leave all the attributes in the img tags, and it works with rollovers, most versions on the net do not support rollovers.
|
|
|
Post by Me on Feb 7, 2007 19:11:43 GMT
Does setAttribute work in firefox? I remember having issues with it in the past.
|
|
|
Post by [ $©Ø®Þ!@Ω™ ] on Feb 7, 2007 21:47:24 GMT
The code doesn't need to even load in Firefox, since Firefox can actually display PNGs correctly. Thus, it doesn't really matter, right?
|
|
|
Post by Me on Feb 7, 2007 22:55:22 GMT
The code doesn't need to even load in Firefox, since Firefox can actually display PNGs correctly. Thus, it doesn't really matter, right? Yeah, I guess you're right .
|
|
|
Post by virtuoso on Feb 14, 2007 0:53:57 GMT
Yeah. And, setAttribute does work in Firefox. Even though you can directly target the attribute...
img.src="blah....";
|
|