View previous topic :: View next topic |
Author |
Message |
darkqueliss
Joined: 27 May 2008 Posts: 1058
|
Posted: 05.06.2008 09:32 Post subject: transparetni background u ie6 |
|
|
evo zanima me kad bi išao radit trasnaprentni bg kako bi to izgledalo...
I sad išao sam vidjet na ovaj site http://blog.medianotions.de/en/articles sve super izgleda, prejebeno... kad ono u ie6 katastrofa... jel ima koji način da se transparetni bg vidi i u ie6, jednako kao i u ie7 il ff... |
|
|
Back to top |
|
|
fun.ky
Joined: 05 Jan 2006 Posts: 365 Location: Mostar
|
Posted: 05.06.2008 10:36 Post subject: |
|
|
Here's the code i use (Background images):
Code: | // === SLEIGHT.JS CODE (Copyright© YoungPup) WITH MODIFIED CSS-INLINE IMAGE SUPPORT ========================
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
document.writeln('<style type="text/css">img { visibility:hidden; } </style>');
window.attachEvent("onload", fnLoadPngs);
}
function fnLoadPngs() {
var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
if (itsAllGood && img.src.match(/\.png$/i) != null) {
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 = "images/spacer.gif"; // change this to your own gif
}
img.style.visibility = "visible";
}
}
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
window.attachEvent("onload", alphaBackgrounds);
}
function alphaBackgrounds(){
var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
for (i=0; i<document.all.length; i++){
var bg = document.all[i].currentStyle.backgroundImage;
if (itsAllGood && bg){
if (bg.match(/\.png/i) != null){
var mypng = bg.substring(5,bg.length-2);
document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='scale')";
document.all[i].style.backgroundImage = "url('images/spacer.gif')"; // change this to your own gif
}
}
}
}
|
That also works for PNGs applied as background images (even in external stylesheets). All you have to do is change all mentions of 'images/spacer.gif' in the code above to the location of a 1px*1px transparent GIF.
warning: if you use a DIV (for example) with a PNG24 background image, and that DIV has a hyperlink in it, the hyperlink will become unclickable since the JS works by overlaying the transparent GIF over the element with the PNG. Weird that; someone exploits a bug in IE which fixes another bug.
======================================================
Png kao slike
After searching what seemed like forever, I found a little hack to make IE on Windows allow alpha transparency in PNG images.
I'm sure someone will ask: "Why not just use a GIF?"...
The answer is simple... take a look...
Sample images have been lost
you should download the images and try placing a different color background on them than white. you will then notice that the GIF does not allow true alpha transparency and creates a white border around the image.
all you need to do to make this work is to add this little javascript to your page:
<!--[if gte IE 5.5000]>
<script type="text/javascript" src="pngfix.js"></script>
<![endif]-->
add the following into a monospace text file and name it pngfix.js and place it in the root directory:
Code: | function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
{
for(var i=0; i<document.images.length; i++)
{
var img = document.images[i]
var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
{
var imgID = (img.id) ? "id='" + img.id + "' " : ""
var imgClass = (img.className) ? "class='" + img.className + "' " : ""
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
var imgStyle = "display:inline-block;" + img.style.cssText
var imgAttribs = img.attributes;
for (var j=0; j<imgAttribs.length; j++)
{
var imgAttrib = imgAttribs[j];
if (imgAttrib.nodeName == "align")
{
if (imgAttrib.nodeValue == "left") imgStyle = "float:left;" + imgStyle
if (imgAttrib.nodeValue == "right") imgStyle = "float:right;" + imgStyle
break
}
}
var strNewHTML = "<span " + imgID + imgClass + imgTitle
strNewHTML += " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
strNewHTML += "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
img.outerHTML = strNewHTML
i = i-1
}
}
}
window.attachEvent("onload", correctPNG); |
|
_________________ There is no style definition for good music! |
|
Back to top |
|
|
darkqueliss
Joined: 27 May 2008 Posts: 1058
|
Posted: 05.06.2008 11:13 Post subject: |
|
|
hvala, probat cu kad doma dodem... |
|
|
Back to top |
|
|
LifeCanBeFun
Joined: 28 Apr 2006 Posts: 228 Location: Istra
|
|
Back to top |
|
|
darkqueliss
Joined: 27 May 2008 Posts: 1058
|
Posted: 05.06.2008 22:36 Post subject: Re: transparetni background u ie6 |
|
|
uspio sam ovo s jednom drugom skriptom, e sad me zeza to što linkani logo.png u ie6 pokazuje tako da uz sliku dobijes i onaj X i alt... tj prikazuje se border, kako rješit to?
border:none; ne šljaka.... |
|
|
Back to top |
|
|
LifeCanBeFun
Joined: 28 Apr 2006 Posts: 228 Location: Istra
|
Posted: 06.06.2008 01:14 Post subject: |
|
|
to je isto rjeseno preko ovog što sam ti linkao... imas blank.gif koji prekrije to tako da ti se x ne pojavljuje |
_________________ www.netlex.hr |
|
Back to top |
|
|
killa
Joined: 12 Sep 2003 Posts: 277 Location: zagreb
|
|
Back to top |
|
|
darkqueliss
Joined: 27 May 2008 Posts: 1058
|
Posted: 06.06.2008 09:39 Post subject: |
|
|
LifeCanBeFun wrote: | to je isto rjeseno preko ovog što sam ti linkao... imas blank.gif koji prekrije to tako da ti se x ne pojavljuje |
evo sad radi... al ne kuzim, sad na srednjem divu mi je nestao bg, a ostali su dobri... lol kako me hebe ovo... posalo sam ti PM, pa ako uhvatiš vremena da pogledaš...
taj bg na srednjem divu nestao je samo u ie7, i ie6... u FF se vidi...
hvala |
|
|
Back to top |
|
|
darkqueliss
Joined: 27 May 2008 Posts: 1058
|
Posted: 17.06.2008 00:29 Post subject: |
|
|
zakaj ne prolazi ovaj vrag validaciju, jel se da kako to rjesit?
|
|
|
Back to top |
|
|
dr_Hate
Joined: 28 Aug 2007 Posts: 168 Location: Rijeka
|
Posted: 17.06.2008 01:10 Post subject: |
|
|
jasi wrote: | zakaj ne prolazi ovaj vrag validaciju, jel se da kako to rjesit? |
direktno u glavu/head sutni pa ce proci validaciju
Code: | <!--[if lt IE 7]>
<style type="text/css">
* html body{behavior: url("iepngfix.htc");}
</style>
<![endif]--> |
|
_________________ imam domenu |stajduhar.org| |
|
Back to top |
|
|
darkqueliss
Joined: 27 May 2008 Posts: 1058
|
Posted: 17.06.2008 08:25 Post subject: |
|
|
sad prolazi validaciju, ali u ie6 ne šljaka, nije transparentni bg...
kaj da radim? |
|
|
Back to top |
|
|
Nemesis
Joined: 01 Oct 2005 Posts: 732
|
Posted: 17.06.2008 09:50 Post subject: |
|
|
Savjetuj ljudima na ulazu da updateaju browsere ili instaliraju firefox. Posebno se potrudi isprdati ljude koji koriste IE6 ili nedaj Bože IE5 jer imaju browser star 5 godina i kako ih nije sram.
E da, ispod stavi Google Adsense koji nudi $1 po downloadu i instalaciji Firefoxa... |
_________________ Webastično.com | Last.fm | Twitter |
|
Back to top |
|
|
darkqueliss
Joined: 27 May 2008 Posts: 1058
|
Posted: 17.06.2008 10:00 Post subject: |
|
|
Nemesis wrote: | Savjetuj ljudima na ulazu da updateaju browsere ili instaliraju firefox. Posebno se potrudi isprdati ljude koji koriste IE6 ili nedaj Bože IE5 jer imaju browser star 5 godina i kako ih nije sram.
E da, ispod stavi Google Adsense koji nudi $1 po downloadu i instalaciji Firefoxa... |
lol nije loša ideja, da bar hoće ukinuti sve IE-ove, osim sedmice... |
|
|
Back to top |
|
|
dr_Hate
Joined: 28 Aug 2007 Posts: 168 Location: Rijeka
|
Posted: 17.06.2008 12:00 Post subject: |
|
|
jasi wrote: | sad prolazi validaciju, ali u ie6 ne šljaka, nije transparentni bg... |
e to ne znam, sorry, ja sam to koristio za sekundarnu navigaciju i csshover2.htc, ne za transparentni bg |
_________________ imam domenu |stajduhar.org| |
|
Back to top |
|
|
darkqueliss
Joined: 27 May 2008 Posts: 1058
|
Posted: 17.06.2008 12:22 Post subject: |
|
|
dam, jel zna netko možda kak složit da prolazi validaciju?
edit: netreba slozio sam sa gifom... |
|
|
Back to top |
|
|
|