问题
I want to read text file using javascript not using imacros loop
I tried to read it using java with no luck
function frdln(n){ var fr,s=''; try{
fr=new java.io.BufferedReader(new java.io.FileReader(n)); s=fr.readLine(); if(s==null){s=''}else{s=''+s}; fr.close(); fr=null; }catch(e){ alert(''+e); }; return s; };
give me message error "ReferenceError: java is not defined"
Note:I installed latest version of java and the same error appear
if there is any other way to read text file or fix my code because I have no idea
回答1:
using javascript this can work XMLHttpRequest() but XMLHttpRequest() is no longer supported in firefox 15+ You must have to define it:
const XMLHttpRequest = Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1"); var request = XMLHttpRequest();
回答2:
Install FireFox 15 and don't update it and that function will work. Java is not supported in FF16+ but in FF15 it works.
来源:https://stackoverflow.com/questions/21953736/imacros-read-text-file-using-javascript