久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

html2canvas網(wǎng)頁截圖

 ProgramCat 2015-05-10

html2canvas網(wǎng)頁截圖,,有需要的朋友可以參考下。


html2canvas工具請自行搜索:

將相應(yīng)的引入的js庫的路徑改變后存到本地即可使用:

HTML頁面一:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!--此網(wǎng)頁演示了html2canvas截圖后將截圖后的網(wǎng)頁追加到了原網(wǎng)頁之上 -->
	<head>
	    <!-- base.js實際上是jquery庫,html2canvas.js是html2canvas自帶的js庫 -->
		<script type="text/javascript" src="./WEB-INF/JS/html2canvas.js"></script>
		<script type="text/javascript" src="./WEB-INF/JS/base.js"></script>
		<title>MyHtml.html</title>

		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="this is my page">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">

		<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<!--需要注意的是,這里一定要等待js庫和網(wǎng)頁加載完畢后再執(zhí)行函數(shù)  -->
		<script type="text/javascript">
$(function(){
     alert("函數(shù)調(diào)用成功");
	html2canvas(document.body, {
		onrendered : function(canvas) {
			document.body.appendChild(canvas);
		}
	});
});
</script>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<style>
.feedback-overlay-black {
	background-color: #000;
	opacity: 0.5;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	margin: 0;
}
</style>

		<style>
div {
	padding: 20px;
	margin: 0 auto;
	border: 5px solid black;
}

h1 {
	border-bottom: 2px solid white;
}

h2 {
	background: #efefef;
	padding: 10px;
}
</style>
	</head>
	<body>
		<div style="background: red;">
			<div style="background: green;">
				<div style="background: blue; border-color: white;">
					<div style="background: yellow;">
						<div style="background: orange;">
							<h1>
								Heading
							</h1>
							Text that isn't wrapped in anything.
							<p>
								Followed by some text wrapped in a
								<b><p> paragraph.</b>
							</p>
							Maybe add a
							<a href="#">link</a> or a different style of
							<a href="#" style="background: white;" id="highlight">link
								with a highlight</a>.
							<hr />
							<h2>
								More content
							</h2>
							<div
								style="width: 10px; height: 10px; border-width: 10px; padding: 0;">
								a
							</div>
						</div>
					</div>

				</div>

			</div>
		</div>
		此網(wǎng)頁演示了html2canvas截圖后將截圖后的網(wǎng)頁追加到了原網(wǎng)頁之上
		<br>
		<br>
		這里可以看作是邊界線
		<hr/>
	</body>
</html>



第二個示例:

將網(wǎng)頁截圖下載:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!--此網(wǎng)頁演示了html2canvas網(wǎng)頁截圖下載 -->
	<head>
	    <!-- base.js實際上是jquery庫,html2canvas.js是html2canvas自帶的js庫 -->
		<script type="text/javascript" src="./WEB-INF/JS/html2canvas.js"></script>
		<script type="text/javascript" src="./WEB-INF/JS/jquery-1.6.2.js"></script>
		<title>MyHtml.html</title>

		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="this is my page">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">

		<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<!--需要注意的是,這里一定要等待js庫和網(wǎng)頁加載完畢后再執(zhí)行函數(shù)  -->
<!-- html2canvas()中,第一個參數(shù)是要截圖的Dom對象,,第二個參數(shù)時渲染完成后回調(diào)的canvas對象,。  -->
		<script type="text/javascript">
$(function(){
	print();
});

function print()
{
	html2canvas( $("body") , 
	{
  		onrendered: function(canvas) 
  		{   
    		$('#down_button').attr( 'href' , canvas.toDataURL() ) ;
    		$('#down_button').attr( 'download' , 'myjobdeer.png' ) ;
    		//$('#down_button').css('display','inline-block');
  		}
  	});
}

</script>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	</head>
	<body>
		此網(wǎng)頁演示了html2canvas截圖后將截圖后的網(wǎng)頁追加到了原網(wǎng)頁之上
		<br>
		<br>
		這里可以看作是邊界線
		<hr/>
<a type="button" id="down_button">下載</a>
	</body>
</html>


    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點,。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多