javascript中的字符串连接在IE9中不起作用

时间:2014-03-14 04:23:58

标签: javascript internet-explorer file-io string-concatenation

嗨我正在阅读图像文件。我在IE 9的后续行中遇到问题

  

finalObj = finalObj + obj [i];

这里字符串连接失败,而finalObj只有obj[0]的值。所以有人可以告诉我如何连接数组中的所有字符串或将数组连接到单个字符串对象中。我尝试使用r.ReadAll()方法仍然获得与finalObj相同的输出。我甚至尝试finalObj = obj.join("")。仍然得到相同的输出。可以有人告诉我我哪里出错或请建议是否有其他方法在IE浏览器的javascript中读取图像文件。

var InternetExplorer = /msie 9.0/i.test(navigator.userAgent);

if (InternetExplorer) { 

        var fso = new ActiveXObject("Scripting.FileSystemObject");
        var r = fso.OpenTextFile(filePath, 1, true);
        var obj=[];
        var count=0;
        while (!r.AtEndOfStream) {
            obj[count] = r.ReadLine();
                        console.log(obj[count])
            count++;
        }

        r.Close();
        var finalObj="";
        for(var i=0;i<obj.length;i++)
            {
                finalObj= finalObj+obj[i]; 
            }
        console.log(finalObj);
}



output of  console.log(obj[count])
is looking like this
LOG: ÿØÿà 
LOG: (1#%(:3=<9387@H\N@DWE78PmQW_bghg>Mqypdx\egcÿÛ 
LOG: 
ÿÄ 
LOG: %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ 
LOG: 
ÿÄ 
LOG: $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ 
LOG: TA‘“’xâœÑºýåb~†ž¬AùF   mÇ&•É4­•„2p¥¿‡® j̺qI       ­YÜÃ!ßò03žù2¹Qòº¶pHUÆ{úRæAÌcK‘D\¸êSÁúÕc#Ÿâ5¹%¾õÎÁ’z×𬻛C^0Z<dà“œ`þŸi   &iŠ¬I’JusÖµ4J=ª@ 
LOG: Öòò    T[ä–U&³R‡5‹³±šÌdR$!qÜð+ZÒÅÅ£,8Fݼázýk¡’ x*±ª×1€`f¦­HFªLJ-£Í1†9âƒÉ­ÍWJ·Id™gò÷pãŒûÅ À9¸ïH† 
LOG: 9*¯n”ÅÏ(SœÒ$š¨=:šÙ'ÊL{Ak8KzSÛP–Pª§zVrMì4ìgÍsSl$€IàOò•Tgõ­[°7b®ÆnB’=@¨iÿ 
LOG: ÜuÏ#'ðô­ª'e°ÒLç[›"LDè2 ãó­;R¿Ž'’yšDÝû½Ê£pÀÏݾêŽö0»¯Njí½¢-´êÛv’ÍŒ…$篧?çšÂ¤¤ Ü…¯ä¼]ÎL   Ì\²®íà `ç±Î8Æ   Ï×E㉔Èî±¢Œ³±ÀÇ®jŒ¶ÑH%‰:‚d7?¨©m­ÝƒíÉ–B9ǦNJáz½M“£C<º–¡#*e™¼³½“G¨Á   ß"¶þÎò©ÇÎGðûÔ‚Úh¢$©,:ð¦Età¼K³ÍòOJÕ'-l+$`xŠE‚ÍTÀÇ{mÏ;G‚}ë•Ý°d¶1Åwž#‰%ÑnD§çdSŽw/9öÿ 
LOG: Ѥõ5=3J»ó´»Gi<Æh—sç98ç×9«³]•ƒ(aÈRzû~UçÖ> ¾²±Š`‰‘I™Xç'=Ö–ó]Õn"D%aŸõCæ==É¥u:”ÚI…ÎÆÜ®£³£kìÙœí sϯ5qo$Oº'dqÑ”àÕ?
jö:n-½üÆL¥ÂØä\tÕÑÛ]YjvbâÙ·)êÁSè}ëŽprwE+XÍŸX»·´YcT’`v”‘2­ÇQŽsÇNœþSèêM°ò¢,?;þ9ª—OÞÇf>ö7“´ôähm;p 
LOG: “Oóšiµ±JM<5{,º³-ÌÏ!–2y'$ãÛÕ«¬jëmºÖ 
LOG: šhttp://ns.adobe.com/xap/1.0/ 
LOG: <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2-c020 1.124078, Tue Sep 11 2007 23:21:40        "> 
LOG:    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> 
LOG:        <rdf:Description rdf:about="" xmlns:tiff="http://ns.adobe.com/tiff/1.0/" xmlns:xap="http://ns.adobe.com/xap/1.0/" xmlns:MicrosoftPhoto_1_="http://ns.microsoft.com/photo/1.0/" xmlns:xapMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:exif="http://ns.adobe.com/exif/1.0/" xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/" xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" xmlns:xapRights="http://ns.adobe.com/xap/1.0/rights/" xmlns:dc="http://purl.org/dc/elements/1.1/" tiff:artist="Amish Patel" tiff:Orientation="1" tiff:ImageWidth="1024" tiff:ImageLength="768" tiff:PhotometricInterpretation="2" tiff:SamplesPerPixel="3" tiff:XResolution="96/1" tiff:YResolution="96/1" tiff:ResolutionUnit="2" xap:Rating="3" xap:CreateDate="2008-03-24T23:41:53Z" xap:ModifyDate="2008-03-24T11:32:16.02-07:00" xap:MetadataDate="2009-02-02T11:42:13-08:00" MicrosoftPhoto_1_:Rating="38" xapMM:InstanceID="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b" exif:ExifVersion="0221" exif:DateTimeDigitized="2008-03-24T11:32:16.02-07:00" exif:PixelXDimension="1024" exif:PixelYDimension="768" exif:ColorSpace="65535" crs:AlreadyApplied="True" photoshop:ColorMode="3" photoshop:ICCProfile="" photoshop:LegacyIPTCDigest="D8C6D45748682E129DC237B6CE3E2B58" xapRights:Marked="True"> 
LOG:            <tiff:BitsPerSample> 
LOG:                <rdf:Seq> 
LOG:                    <rdf:li>8</rdf:li> 
LOG:                    <rdf:li>8</rdf:li> 
LOG:                    <rdf:li>8</rdf:li> 
LOG:                </rdf:Seq> 
LOG:            </tiff:BitsPerSample> 
LOG:            <dc:creator> 
LOG:                <rdf:Seq> 
LOG:                    <rdf:li>Amish Patel</rdf:li> 
LOG:                </rdf:Seq> 
LOG:            </dc:creator> 
LOG:            <dc:rights> 
LOG:                <rdf:Alt> 
LOG:                    <rdf:li xml:lang="x-default">© Microsoft Corporation</rdf:li> 
LOG:                </rdf:Alt> 
LOG:            </dc:rights> 
LOG:        </rdf:Description> 
LOG:    </rdf:RDF> 
LOG: </x:xmpmeta> 
LOG:                                                                                                      
LOG:                                                                                                      
LOG:                                                                                                      
LOG:                                                                                                      
LOG:                                                                                                      
LOG:                                                                                                      
LOG:                                                                                                      
LOG:                           <?xpacket end='w'?>ÿí 
LOG:  
LOG:  
LOG: ÁÑ5'áS6‚ñ’¢DTsEF7Gc(UVW²ÂÒâòdƒt“„e£³ÃÓã)8fóu*9:HIJXYZghijvwxyz…†‡ˆ‰Š”•–—˜™š¤¥¦§¨©ª´µ¶·¸¹ºÄÅÆÇÈÉÊÔÕÖ×ØÙÚäåæçèéêôõö÷øùúÿÄ 
LOG: 
and so on ............

the output of console.log(finalObj) is 
LOG: ÿØÿà


Thanks in Advance..

0 个答案:

没有答案