注意,只能删除行注释

通过修改第28行代码if(temp.indexOf("'")!=0),将indexOf'修改为对应语言的注释符就可以达到删除对应语言行注释的效果

<html>
    <head>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css">
        <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
        <script src="http://code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
    </head>
    <body>
        <script>
            function PreviewText() {
				var oFReader = new FileReader();
				oFReader.readAsDataURL(document.getElementById("uploadText").files[0]);
				oFReader.onload = function (oFREvent) {
					document.getElementById("uploadTextValue").value = oFREvent.target.result; 
					//oFREvent.target.result);
				var decodedString = atob(oFREvent.target.result.split("base64,")[1]);


                var string = "";
                var lines = decodedString.split('\n');
					var fruits = [];
					for(var i = 0;i < lines.length;i++){
						
				
 var temp = lines[i];
 
//去掉所有的空格(中文空格、英文空格都会被替换)
temp = temp.replace(/\s/g,"");
if(temp.indexOf("'")!=0)
//输出转换后的字符串
string = string+ lines[i];
                    }
                    document.getElementsByTagName('xmp')[0].innerHTML=string;
			    };
            }
        jQuery(document).ready(function(){
            $('#viewSource').click(function ()
            {
                var text = $('#uploadTextValue').val();
                alert(text);
                //here ajax
            });
        });
        </script>
        <xmp></xmp>
        <div>
            <input type="hidden" id="uploadTextValue" name="uploadTextValue" value="" />
            <input id="uploadText" style="width:120px" type="file" size="10"  onchange="PreviewText();" />
        </div>
        <a href="#" id="viewSource">Source file</a>
    </body>
</html>