在微信中实现HTML页面保存成图片
16lz
2021-01-22
在微信中实现HTML页面保存成图片,长按页面可以把页面保存为图片
jQuery(document).ready(function(){
if(isWeiXin()){
var img = new Image();
img.src='images/touxiang.jpg';
img.onload = function(){
var elem = jQuery('#content');
html2canvas([elem.get(0)], {
onrendered: function (canvas) {
var image = canvas.toDataURL("image/jpg");
var pHtml = "<img src='"+image+"' style='width:100%;height:100%'>";
jQuery("#content").html(pHtml);
jQuery("#content").attr("style","padding-top:40px");
}
});
}
}
});
//判断是否为微信
function isWeiXin(){
var ua = window.navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
return true;
}else{
return false;
}
}
更多相关文章
- html页面输出pdf格式文件(一步步很详细)
- 为什么我的html页面的大小不固定啊?
- 小强的HTML5移动开发之路(53)——jQueryMobile页面间参数传递
- Js 之将html转为图片html2canvas
- Web前端-html页面-做过的一个公司的主页
- html页面中给img标签的src属性赋值为一张图片的存储路径,图片不显
- HTML5批量拖拽图片到网页
- 加载跨域的HTML页面AJAX
- HTML5,简单的注册页面