-
Notifications
You must be signed in to change notification settings - Fork 209
how to listen page by on? #33
Comments
See the documentation about evaluated functions. |
I checked the documentation but I think I still don't understand how this is supposed to work. I understand that I have to use JsFunction, I think I know how to create one, but how do I get back the result in PHP?
how do I get the status in PHP? Is there an example I have missed? If it's not, can it be please created? |
I should document this. You can listen for an event and react to it, however it’s currently impossible to transmit a value to PHP from a JS event. |
How to do this, whether to consider adding in the future |
I tried to do this, but something went wrong. $function = JsFunction::create(['request'], "
fs = require('fs');
fs.writeFileSync('request.txt', request.url());
");
$page->on('requestfailed', $function); PHP Fatal error: Uncaught Nesk\Rialto\Exceptions\Node\FatalException: require is not defined in /Users/lixiang/Documents/data/wwwroot/yii3/vendor/nesk/rialto/src/ProcessSupervisor.php:307 |
page.on('requestfailed', function (request) {
fs = require('fs');
fs.writeFileSync('request.txt', request.url());
}); In nodejs, this works fine |
This is because JS functions in PuPHPeteer are created with the page.on('requestfailed', new Function('request', `
fs = require('fs');
fs.writeFileSync('request.txt', request.url());
`)); This will fail because the body of the function doesn't have access to the I agree this is an issue and should be fixed, I've created an issue for this: rialto-php/rialto#19 |
Please resolve this issue, Mr Nesk and All!The example above , i till dont understand. |
when i simulate to login some website to get cookie, there comes alert dialog. how to write like js code below same with php?
The text was updated successfully, but these errors were encountered: