Teo*_*ahi 5 safari screenshot safari-extension
我正在开发safari浏览器扩展,它应具有截屏功能.
Chrome和Firefox有自己的api来获取当前窗口文档的SS.我找不到任何特定于Safari的API文档. Windows和Tabs API
实现它的最佳方法是什么?
SafariBrowserTab有一种visibleContentsAsDataURL方法来获取当前可见内容的图像数据.
例如,在您的全局页面中:
safari.application.addEventListener('command', performCommand, false);
// Perform e.g. when toolbar button is clicked
function performCommand(event) {
if (event.command === 'captureTab') {
var tab = safari.application.activeBrowserWindow.activeTab;
tab.visibleContentsAsDataURL(function(imgdata) {
//console.log(imgdata);
// Do something...
// e.g. Send to an injected script to display image on page:
tab.page.dispatchMessage('imgData', imgdata);
});
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1070 次 |
| 最近记录: |