• JS——图片预览功能


    <script type="text/javascript">
        function DisplayImage(fileTag) {
            document.getElementById('viewfile').value = fileTag.value;
            fileTag.style.display = 'none';
            var allowExtention = ".jpg.png.gif.JPG.PNG.GIF";
            var extentionArr = fileTag.value.split('.');
            var extention = extentionArr[extentionArr.length - 1];
            if (!(allowExtention.indexOf(extention) > -1)) {
                alert("请选择图片!");
            } else {
                //for adveced broswer(the newest ie,chrome,ff)
                if (typeof (FileReader) !== "undefined") {

                    var reader = new FileReader();
                    reader.readAsDataURL(fileTag.files[0]);
                    reader.onload = function (e) {
                        document.getElementById("img_1").setAttribute("src", e.target.result);
                    }
                } else {
                    //for(ie6)
                    document.getElementById("img_1").setAttribute("src", fileTag.value);
                }
            }
        }
    </script>

  • 相关阅读:
    HDU 1097 a hard puzzle
    HDU 4588 Count The Carries
    不想用锐捷怎么办?锐捷出问题|锐捷不能用怎么办?用menohust代替吧
    线段树及其变种的相关资料(不定期更新)
    UVa 10075
    UVa 1301
    UVa 10256
    UVa 1453
    计算几何相关资料+题目推荐(不定期补充)
    UVa 11524
  • 原文地址:https://www.cnblogs.com/witeem/p/5502360.html
Copyright © 2020-2023  润新知