Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript]Rollover + pngfic + IE
dexter77
post 11.07.2008, 00:14:15
Post #1





Grupa: Zarejestrowani
Postów: 27
Pomógł: 0
Dołączył: 6.05.2008

Ostrzeżenie: (0%)
-----


Witam, mam pewien problem, zastosowalem image rollover java script ...podmieniajace sie obrazki to PNG, a wiec IE ich nie wyswietla poprawnie... aby to rozwiazac uzylem pngfix.js ....i tutaj pojawia sie problem, poniewaz pod FF i Opera wszystko ok, a pod IE skrypty chyba sie gryzą bo obrazki nie sa podmieniane, zostaje tylko glowny...

podaje kod strony:

Kod
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
     "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   <meta name="Title" content="xx" />
   <meta name="Description" content="xx">
   <meta name="author" content="xx" />
   <meta http-equiv="reply-to" content="xx" />
   <meta name="description" content="xx" />
   <meta name="keywords" content="xx" />
   <meta http-equiv="content-language" content="pl" />
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-2" />
   <title>xx</title>
   <link rel="stylesheet" href="style.css" type="text/css">
<!--[if lt IE 7.]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->
<script language="Javascript">
<!--

if (document.images) {
      button1 = new Image
      button2 = new Image

      button1.src = 'images/start.png'
      button2.src = 'images/start-over.png'
  }
//-->
</script>
</head>
<body>
<div id="start"><img src="images/start01.png" width="601" height="128"><br>
<a href="" onmouseover="document.rollover.src=button2.src" onmouseout="document.rollover.src=button1.src"><img src="images/start.png" width="601" height="286" border=0 name="rollover"></a>

</div>
</body>
</html>


a oto pngfix.js:

Kod
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters))
{
    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
          if (img.align == "left") imgStyle = "float:left;" + imgStyle
          if (img.align == "right") imgStyle = "float:right;" + imgStyle
          if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
          var strNewHTML = "<span " + imgID + imgClass + imgTitle
          + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
          + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
          + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
          img.outerHTML = strNewHTML
          i = i-1
       }
    }
}


jak rozwiazac ten problem, aby rollover z PNG działał nie tylko pod FF ale tez w IE ? sad.gif

Ten post edytował dexter77 11.07.2008, 10:09:30
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 19:12