所以我的情況如下:的Javascript隨機重定向
我寫一個PHP提交系統寫入到一個文本文件,而不是一個數據庫,該系統的想法是人提交的URL文本文件,然後當該腳本在頁面上調用,它將重定向到文本文件中的隨機地址;問題是,我不知道如何讓JavaScript從文本文件中讀取,然後選擇一行重定向到。其實,只是爲了澄清,我知道如何讓JavaScript從文本文件中讀取;但我不知道如何編寫一個函數從文件中選擇一個URL並轉發給它。
看到,因爲我打這條道路阻斷前兩天,我一直在處理意見書的唯一方法是手動檢查文本文件對新提交的每12小時,然後將它們加入到這個代碼:
setTimeout(function() {
var howMany = 38;
var page = new Array(howMany+1);
page[0]="http://gproxy.nl/";
page[1]="http://homeproxy.me/";
page[2]="http://proxyturbo.com/";
page[3]="http://www.lblocker.info/";
page[4]="http://goprivate.eu/";
page[5]="http://jsproxy.com/";
page[6]="http://openthis.eu/";
page[7]="http://proxy4home.info/";
page[8]="http://dedicatedipaddress.net/";
page[9]="https://www.4everproxy.com/";
page[10]="http://www.surfsearch.info/";
page[11]="http://www.leaveproxy.com/";
page[12]="http://proxyecole.fr/";
page[13]="http://newipnow.com/";
page[14]="http://www.hiddenmode.info/";
page[15]="https://europrox.org/";
page[16]="https://www.4everproxy.com/";
page[17]="https://goingthere.org/";
page[18]="http://xuxor.com/";
page[19]="http://033b.com/";
page[20]="http://thewebtunnel.com/";
page[21]="http://prox.phanteye.com/";
page[22]="http://www.hiddenall.info/";
page[23]="http://www.5966.info/";
page[24]="http://hideyoself.com/";
page[25]="http://prox.phanteye.com/";
page[26]="http://freevideoproxy.com/";
page[27]="http://thewebtunnel.com/";
page[28]="http://openthis.eu/";
page[29]="https://europrox.org/";
page[30]="http://xuxor.com/";
page[31]="https://incloak.com/";
page[32]="http://www.leaveproxy.com/";
page[33]="http://www.openunblocker.com/";
page[34]="http://post48.com";
page[35]="http://post48.com";
page[36]="http://inteproxy.com";
page[37]="http://208.73.23.59";
page[38]="http://hidemetoday.com/";
function rndnumber(){
var randscript = -1;
while (randscript < 0 || randscript > howMany || isNaN(randscript)){
randscript = parseInt(Math.random()*(howMany+1));
}
return randscript;
}
quo = rndnumber();
quox = page[quo];
window.location=(quox);
}, 1500);
如果有人會幫我編寫腳本或告訴我應該使用Google搜索來查找什麼樣的功能,Google會非常感激,「如何讓javascript從文本文件中讀取並重定向」實際上並不多; (
非常感謝
儘管這不是一個答案,但我覺得有必要指出JavaScript與Java完全不同,因此不應將此問題列入Java類別中。 – caseif
爲什麼在發佈的代碼運行時不工作?會發生什麼,而不是你所期望的? –
如果PHP讀取文件併發送隨機鏈接到客戶端,而不是發送完整的URL的整個文本文件不是更好。 –