1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <body onload="initializePage();">
<script type="text/javascript">
function initializePage() {
var fileName = "toto.txt";
var currentFolder = GetCurrentFolder();
var fileContent = LoadUrlFile(currentFolder + "/" + fileName);
console.log( fileContent);
}
function GetCurrentFolder() {
var myloc = window.location.href;
var locarray = myloc.split("/");
delete locarray[(locarray.length-1)];
var arraytext = locarray.join("/");
return arraytext;
}
function LoadUrlFile(url){
var http = new XMLHttpRequest();
http.open('GET', url, false);
http.send(null);
return http.response;
}
</script>
</body> |
Partager