如何展示html2canvas'画布'在新的extJS对话框/面板中
how to show html2canvas 'canvas' in new extJS dialog/panel?
我正在使用html2canvas
,在此处获取画布值:
makeScreenshot: function(button)
{
debugger;
//window.location.href = "mai lto:mail@example.org";
html2canvas(document.body, {
onrendered: function(canvas) {
document.body.appendChild(canvas);
},
width: 600,
height: 600
});
},
如何在extjs的一些窗口、对话框或面板中显示它?是否有可能更改screenshot
的大小?
我想要那样的东西!我错了…
makeScreenshot: function(button)
{
debugger;
//window.location.href = "mai lto:mail@example.org";
var screenshotHtml;
html2canvas(document.body, {
onrendered: function(canvas) {
screenshotHtml = document.body;
}
});
var win = new Ext.Window({
title: 'Screenshot',
width: 1024,
height: 640,
resizable: true,
autoScroll: true,
preventBodyReset: true,
html: screenshotHtml
});
win.show();
},
下面是我如何做到这一点的快速示例
我基本上将其转换为数据url并设置图像大小。
画布部分:
buttons: [{
text: 'Login',
handler: function (button) {
var win = button.up('window');
html2canvas(document.body, {
onrendered: function (canvas) {
var c = win.down('form container'),
img = new Image();
img.height = 100;
img.src = canvas.toDataURL("image/png");
c.getEl().dom.appendChild(img);
}
});
}
}]
更新
这是一个新的小提琴
您可以将您的功能简化为:
makeScreenshot: function (button) {
debugger;
//window.location.href = "mailto:mail@example.org";
html2canvas(document.body, {
onrendered: function (canvas) {
new Ext.Window({
title: 'Screenshot',
width: 500,
height: 400,
resizable: true,
autoScroll: true,
preventBodyReset: true,
html: '<img src="' +canvas.toDataURL("image/png") +'" height="200"/>'
}).show();
}
});
}
我调整了图像的大小,并将其设置为height=200
。您可以根据自己的喜好设置高度/宽度,就像对每张图像所做的那样。还有小提琴,我把窗户设置为500*400,否则我看不到整个窗户。
相关文章:
- 着色引导框对话框
- 文本框不是从Javascript/Asp.net中的对话框中打印出来的
- CKeditor:更改对话框中的默认选择选项
- 搜索api在mac上显示对话框
- 使用密码对话框Javascript请求帮助
- CKEditor v4:自制插件中对话框的动态标题
- 删除确认对话框在第一次单击时不起作用
- 使用jquery对话框中的箭头键
- 获取打开jquery对话框的button的id
- 是否可以用JavaScript显示等效的文件夹对话框
- 我怎么能让jQuery对话框表现得像Javascript警报
- 如何在页面重新加载时显示jquery ui对话框
- 打开相对于鼠标位置的CSS3/HTML5模式对话框
- javascript确认对话框有时会不断出现
- 如何为javascript方法放入jquery确认对话框
- Jquery UI对话框不会消失
- 如何从自定义对话框编辑数据网格中的选定行
- OnsenUI、Angular和在警报对话框后刷新UI组件
- jQuery UI对话框错误,按钮导致HierarchyRequestError
- 如何展示html2canvas'画布'在新的extJS对话框/面板中