<html>
    <head>
        <title></title>
        <script>
            function readTextFile(file)
            {
                    var rawFile = new XMLHttpRequest();
                    rawFile.open("GET", file, false);
                    rawFile.onreadystatechange = function ()
                    {
                        if(rawFile.readyState === 4)
                        {
                                if(rawFile.status === 200 || rawFile.status == 0)
                                {
                                    var splitResponse = rawFile.responseText.split( "\n" );
                            for(index = 0; index < splitResponse.length; index++) 
                            {
                                    window.open(splitResponse[index]);
                            } 
                            
                            
                                }
                        }
                    }
                    rawFile.send(null);
            }
        </script>
    </head>
    <body>
        <script language="JavaScript">
            readTextFile("./file.txt");
        </script>
    </body>
</html>

arrow
arrow
    文章標籤
    javascript read file split
    全站熱搜

    痞客興 發表在 痞客邦 留言(0) 人氣()