javascript - How to use callback in sandbox in firefox add-on on android? -
i want execute sided javascript code in firefox add-on program on android. how call method of main page's script sided js code?
main code:
function execjavascript(awindow, itemid, password) { var xmlhttppost = new awindow.xmlhttprequest(); if (xmlhttppost.overridemimetype) xmlhttppost.overridemimetype('text/html'); xmlhttppost.open( 'post', 'http://localhost:'+port+'/home.html?msgfill='+itemid+'msgpasswd='+password, false); xmlhttppost.setrequestheader('content-type', 'application/x-www-form-urlencoded'); xmlhttppost.send('msg=hello'); // execute received javascript var javascript = xmlhttppost.responsetext; try { // try execute received javascript evalinsandbox(awindow, javascript); } catch(e) { showtoast(awindow, e.message); } } function callbackfromloadedjs(string result) { console.log("callback result = " + result); }
i want send result sided javascript.
var javascript = readfilecontent(); var sandbox = new components.utils.sandbox(window); sandbox.window = window; components.utils.evalinsandbox(javascript, sandbox); sandbox.themethodyouneedtocall();
Comments
Post a Comment