html2canvas 在 Firefox 中有效,但在 Chrome 中无效
我正在捕获 iframe 中存在的 Scorm 内容的屏幕截图,我在 Firefox 中获得屏幕截图,但在 Chrome 中却没有,问题似乎出在渲染到画布时的图像路径/URL。
我比较了结果来自两个浏览器的 logging: true
。
而且我发现 chrome 中的图像路径已更改,这就是它在 chrome 中不起作用的原因。
我该如何解决这个问题?帮助我......
var iframeEle = document.querySelector("iframe").contentWindow.document.body;//working
console.log(iframeEle);
// $('#saveReport').on('click', function(){
html2canvas(iframeEle, {
//background: '#fff',
// height: window.innerHeight,
//windowHeight: window.innerHeight,
logging: true,
onrendered: function(canvas){
// before_imgData = canvas.toDataURL('image/png');
before_imgData = canvas.toDataURL('image/jpeg');
}
});
firefox 浏览器日志:
当我检查渲染图像的路径时,它是正确的。
Chrome 浏览器日志:
在 Chrome 中,图像路径不正确,因为它由浏览器的当前 url 组成,这就是为什么无法正确捕获的原因。
我认为这是 chrome 相对路径的问题,而不是 firefox 的问题。
I am capturing the screenshot of the Scorm content present inside the iframe, I am getting screenshot in the firefox but not in chrome, it seems like issue is with images path/url while rendering into the canvas.
I have compared the result of logging: true
from both browser.
And I found that images path in the chrome is changed that's why it is not working in chrome.
How can i solve this? help me........
var iframeEle = document.querySelector("iframe").contentWindow.document.body;//working
console.log(iframeEle);
// $('#saveReport').on('click', function(){
html2canvas(iframeEle, {
//background: '#fff',
// height: window.innerHeight,
//windowHeight: window.innerHeight,
logging: true,
onrendered: function(canvas){
// before_imgData = canvas.toDataURL('image/png');
before_imgData = canvas.toDataURL('image/jpeg');
}
});
Log for firefox browser :
when I checked path of images for rendering it is correct.
Log for chrome browser :
in chrome the path for images is not right as it consist of current url of browser thats why is not capturing correctly.
I think it is issue of relative path for chrome and not for firefox.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论