0

我有一个网站 - http://gap.quotamarketing.co.uk/ - 在这个网站上我有一个 pngfix。我也有一个闪光对象。

在我需要支持的 IE6 中,flash 对象之后的每个图像都不包含在 png 修复用于循环图像的 document.images 中,因此不会应用 png 修复。有什么想法可以让其余的图像出现在这个列表中吗?(我正在寻找替换亮边组徽标,它确实显示为新图像)

非常感谢任何帮助!

修复脚本:

// JavaScript Document
/*

Correctly handle PNG transparency in Win IE 5.5 & 6.
http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.

Use in <HEAD> with DEFER keyword wrapped in conditional comments:
<!--[if lt IE 7]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->

*/

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
      }
   }
}
4

1 回答 1

1

我不熟悉 pngfix,但您应该考虑使用SWFObject嵌入您的 Flash 对象。然后,您可以延迟 Flash 对象插入页面,直到您的 pngfix 完成。因为您的 pngfix 脚本用于defer将其执行推迟到页面加载完毕,您将不得不采取类似的措施来延迟 SWFObject 的初始化。

我这样做的方法是在条件注释块中设置一个变量,我们可以在外面检查。如果它不存在,那么您可以继续使用 SWFObject 嵌入 SWF,否则,您将从 pngfix 脚本的末尾调用嵌入。

<!--[if lt IE 7]>
<link href="includes/ie6print.css" rel="stylesheet" type="text/css" media="print" />
<link href="includes/ie6template.css" rel="stylesheet" type="text/css" media="screen" />

<script type="text/javascript">var horribleOldBrowser = true;</script>

<script defer type="text/javascript" src="includes/pngfix.js"></script>
<![endif]-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript">
    if(typeof horribleOldBrowser === 'undefined') {
        //must not be using pngfix, let's embed with swfobject now
        swfobject.embedSWF("Flash/formFlash2.swf", "myTargetContainer", "300", "210", "9.0.0");
</script>

然后,在 pngfix 脚本的末尾,您再次放入同一行 Javascript 以在一切完成后嵌入 swfobject。

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
      }
   }
   swfobject.embedSWF("Flash/formFlash2.swf", "myTargetContainer", "300", "210", "9.0.0"); 
}
于 2011-07-27T14:07:21.630 回答