[英]javascript reading from txt file by order
得到了以下脚本,该脚本将txt文件中的网址放入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>
我的问题-它没有按顺序排列网址,我希望它从底部或顶部开始,然后依次一个按顺序排列。 我怎么做?
尝试这个
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;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.