我在HTML正文中包含以下代码,其中包含div元素中的几个图像。我想捕获整个看到的,因为它在webview上可见。
<div data-win-control="SdkSample.ScenarioOutput" id="grid">
<img id ="Img0" src="/images/0.png" class="GestureTile"/>
<img id ="Img1" src="/images/1.png" class="GestureTile"/>
<img id ="Img2" src="/images/2.png" class="GestureTile"/>
<img id ="Img3" src="/images/3.png" class="GestureTile"/>
<img id ="Img4" src="/images/4.png" class="GestureTile"/>
<img id ="Img5" src="/images/5.png" class="GestureTile"/>
<img id ="Img6" src="/images/6.png" class="GestureTile"/>
<img id ="Img7" src="/images/7.png" class="GestureTile"/>
<img id ="Img8" src="/images/8.png" class="GestureTile"/>
<img id ="Img9" src="/images/9.png" class="GestureTile"/>
</div>
是否可以直接通过winjs捕获,还是应该采用其他方式?
谢谢,
答案 0 :(得分:0)
据我所知(我很乐意听到),唯一可以捕获的是画布的内容。我认为你不能捕获渲染的HTML。遗憾。
答案 1 :(得分:0)
我知道主题有点旧,但是从8.1开始,您可以grab the webview content as a Blob然后随意做任何事情(将其发送到服务器,创建数据URI并将其放入{{ 1}}等...
<img>
我还没有实现这个,所以我不能说是否有任何陷阱。
<强>更新强>
所以我尝试实现上面的内容,这就是它在文档中所说的内容,但它对我不起作用。我要离开它,因为下面的评论者说这对他们有用。对我来说,我必须使用下面的代码,因为myWebview.capturePreviewToBlobAsync().done(
function(imgBlob) {
// do whatever you need to with the Blob
},
function(err) {
// handle errors... not sure what you might get here, honestly
}
);
方法没有返回承诺。不知道为什么......
capturePreviewToBlobAsync
查看example on this page(搜索“capturePreviewToBlobAsync”)。