1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <!DOCTYPE html> < html > < head > </ head > < body > < h1 >Test page</ h1 > < p >Hello!</ p > < script type = "text/javascript" > var dummyscript = document.createElement('script'); // Register error function where the file does not exist. dummyscript.onerror = function() { if (dummyscript.onerror) alert("The file does not exist."); } // Append some random data to the file name so that the browser cache doesn't serve an old result. dummyscript.src = "file:///C:/Temp/testfile?" + new Date().getTime() + Math.floor(Math.random() * 1000000); // Load dummy script document.body.appendChild(dummyscript); </ script > </ body > </ html > |
But, the web browser displays "Not allowed to load local resource: file:///C:/Temp/testfile?~~~~~~".