0

得到了这个脚本,它将 txt 文件中的 urls 放入 i 框架并一个一个地加载它们:

<script type="text/javascript">
    $.get("imones.txt", function (data) {
        var array = data.split(/\r\n|\r|\n/);
        var beforeLoad = (new Date()).getTime();
        var loadTimes = []; 
        var beforeTimes = [];   
        $('#frame_id').on('load', function () {                                 
            beforeTimes.push(beforeLoad);
            loadTimes.push((new Date()).getTime()); 
            $('#frame_id').attr('src', array.pop()); 
            $.each(loadTimes, function (index, value) {
                var result = (value - beforeTimes[index]) / 1000; 
                if (result < 0) { 
                    result = result * (-1);
                }   
                $("#loadingtime" + index).html(result);
                beforeLoad = value;
            });
        }).attr('src', array.pop());
    });
</script>

我的问题 - 它不是按顺序放置 url,我希望它从底部或顶部开始,然后按顺序排列。我怎么做?

4

1 回答 1

0

尝试这个

var txtFile = new XMLHttpRequest();
txtFile.open("GET", "imones.txt", true);
txtFile.onreadystatechange = function() 
{
 if (txtFile.readyState === 4)   // Makes sure the document is ready to parse.
 {
  if (txtFile.status === 200)   // Makes sure it's found the file.
   {
    allText = txtFile.responseText; 
   }
 }
}
于 2013-03-05T07:55:28.513 回答