MediaWiki:Common.js/IE60Fixes.js

提供: メディカルウェア
移動: 案内検索

注意: 保存後、変更を確認するにはブラウザーのキャッシュを消去する必要がある場合があります。

  • Firefox / Safari: Shift を押しながら 再読み込み をクリックするか、Ctrl-F5 または Ctrl-R を押してください (Mac では ⌘-R)
  • Google Chrome: Ctrl-Shift-R を押してください (Mac では ⌘-Shift-R)
  • Internet Explorer: Ctrl を押しながら 最新の情報に更新 をクリックするか、Ctrl-F5 を押してください
  • Opera: ツール → 設定 からキャッシュをクリアしてください。
//<source lang="JavaScript">
 
/** 
 * Correctly handle PNG transparency in Internet Explorer 6.
 * http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.
 *  
 * Adapted for Wikipedia by Remember_the_dot and Edokter.
 *  
 * http://homepage.ntlworld.com/bobosola/pnginfo.htm states "This page contains more information for
 * the curious or those who wish to amend the script for special needs", which I take as permission to
 * modify or adapt this script freely. I release my changes into the public domain.
 */  
 
function PngFix()
{
    try
    {
        if (!document.body.filters)
        {
            window.PngFixDisabled = true
        }
    }
    catch (e)
    {
        window.PngFixDisabled = true
    }
    if (!window.PngFixDisabled)
    {
        var documentImages = document.images
        var documentCreateElement = document.createElement
        var funcEncodeURI = encodeURI
 
        for (var i = 0; i < documentImages.length;)
        {
            var img = documentImages[i]
            var imgSrc = img.src
 
            if (imgSrc.substr(imgSrc.length - 3).toLowerCase() == "png" && img.complete && !img.onclick)
            {
                if (img.useMap)
                {
                    img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + funcEncodeURI(imgSrc) + "')"
                    img.src = "http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif"
                    i++
                }
                else
                {
                    var outerSpan = documentCreateElement("span")
                    var innerSpan = documentCreateElement("span")
                    var outerSpanStyle = outerSpan.style
                    var innerSpanStyle = innerSpan.style
                    var imgCurrentStyle = img.currentStyle
 
                    outerSpan.id = img.id
                    outerSpan.className = img.className
                    outerSpanStyle.backgroundImage = imgCurrentStyle.backgroundImage
                    outerSpanStyle.borderWidth = imgCurrentStyle.borderWidth
                    outerSpanStyle.borderStyle = imgCurrentStyle.borderStyle
                    outerSpanStyle.borderColor = imgCurrentStyle.borderColor
                    outerSpanStyle.display = "inline-block"
                    outerSpanStyle.fontSize = "0"
                    outerSpanStyle.verticalAlign = "middle"
                    if (img.parentElement.href) outerSpanStyle.cursor = "hand"
 
                    innerSpanStyle.width = "1px"
                    innerSpanStyle.height = "1px"
                    innerSpanStyle.display = "inline-block"
                    innerSpanStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + funcEncodeURI(imgSrc) + "')"
 
                    outerSpan.appendChild(innerSpan)
                    img.parentNode.replaceChild(outerSpan, img)
                }
            }
            else
            {
                i++
            }
        }
    }
}
 
function StackTables()
{
    var documentTables = document.getElementsByTagName("table")
    for (var i = 0; i < documentTables.length; i++)
    {
        var table = documentTables[i]
        var tableStyle = table.style
        var prevElement = table.previousSibling
        if (prevElement)
        {
            if (hasClass (table, "navbox") && hasClass (prevElement, "navbox"))
            {
                tableStyle.marginTop = "-1px"
                continue
            }
            if (hasClass (table, "ambox") && hasClass (prevElement, "ambox"))
            {
                tableStyle.marginTop = "-1px"
            }
        }
    }
}
 
window.attachEvent("onload", PngFix)
window.attachEvent("onload", StackTables)
 
//</source>