首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

(转)下传图片预览FF IE

2012-11-08 
(转)上传图片预览FF IEhtmlheadtitleget file input full path/titlescript languagejavascrip

(转)上传图片预览FF IE
<html>
    <head>
        <title>get file input full path</title>
    <script language='javascript'>
        function getFullPath(obj)
        {
            if(obj)
            {
                //ie
                if (window.navigator.userAgent.indexOf("MSIE")>=1)
                {
                    obj.select();
                    return document.selection.createRange().text;
                }
                //firefox
                else if(window.navigator.userAgent.indexOf("Firefox")>=1)
                {
                    if(obj.files)
                    {
                        return obj.files.item(0).getAsDataURL();
                    }
                    return obj.value;
                }
                return obj.value;
            }
        }
    </script>
    </head>
    <body>
        <input type="file" onchange="document.getElementById('img').src=getFullPath(this);" />
    <img id="img" />
    </body>
</html>

热点排行