答えて

2

if (typeof window.callPhantom === 'function') { 
    window.callPhantom({ data: 'RenderPDF' }); 
} 

そしてphantomjsスクリプトの:私は、次のコードを使用して、それが可能であったPhantomJSを使用するために使用されます。

以下の例は、window.callChromeが呼び出されたときに解決される約束を返す関数を評価します。

function callChrome() { 
    return() => { 
    return new Promise((resolve, reject) => { 
     window.callChrome = resolve; 
    }); 
    }); 
} 

// runtime is located in the client object 
Runtime.evaluate({ 
    expression: `(${callChrome()})()`, 
    awaitPromise: true, 
}).then((result) => { 
    // what you've passed into the window.callChrome function. 
}); 

評価される式は次のようになります。

ページの準備が整ったら、実際にこのコードを実行する必要があります。理想的には、Page.loadEventFired機能を使用します。

関連する問題