Reputation: 611
On electronjs i can use executeJavascript on another site and return value like bellow, could i do that on phonegap?
mainWindow.webcontent.executeJavasciprt(someScript)
i found it, using window.open
var ref = window.open('your_url_hear', '_blank');
ref.addEventListener('loadstop', async function() {//wait for url stop loading
ref.executeScript({code: `document.write('123'); function returnvalue(){
var value = 123;
return value
};returnvalue()`},function(value){
//callback return value of the last row of code, we can use ref.executeScript({file:'patch_to_js_file'})
console.log(value)
});
Upvotes: 0
Views: 281
Reputation: 109
you have to run your code as a string type try below code this works fine
win.webContents.executeJavaScript(`alert(${varible_value});`);
Upvotes: 1