خرید بک لینک

Vote count: 0

I am doing a Chrome extention, and I am facing an issue :

I first inject a file.js in a Website open in a Webview.

In this file.js I have a function which execute a retu value include in a setTimeout.

The probleme is when I call the function using executeScript, the callback doesn't wait for the end of setTimeout, and retu [null].

Does someone could tell me what could I do ? thank you!

(Without the setTimeout, it retu the expected value)

//content of file.js
function foo(){
  setTimeout(function (){ retu {key:"value"}; }, 5000);
}

//I inject the file.js in the website
webview.executeScript({file:"file.js"}, function(result){ console.log(result); });

//I call foo() in the website
webview.executeScript( {code:"foo();"}, function(result){ console.log(JSON.stringify(result)); });
asked 1 min ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 16 اسفند 1394 ساعت: 2:23

صفحه بندی