我有一個腳本,按訂單把網址變成一個iframe中:閱讀TXT文件中的數據轉換爲JavaScript陣列
<script type="text/javascript">
$(document).ready(function(){
var array = ['http://www.example1.come', 'http://www.example2.com', 'http://www.example3.com'];
var beforeLoad = (new Date()).getTime();
var loadTimes = [];
$('#1').on('load', function() {
loadTimes.push((new Date()).getTime());
$('#1').attr('src', array.pop());
if (array.length === 0) {
$.each(loadTimes, function(index, value) {
$("#loadingtime"+index).html(value - beforeLoad);
});
}
}).attr('src', array.pop());
});
</script>
我得到的URL列表txt文件。該文件中的URL被寫入一列(1列,每行從新行開始)。我如何可以替換JavaScript中的'var數組'與該txt文件的內容?
+1佔所有不同的可能行尾。 – 2013-02-24 20:19:12