|
@@ -1,46 +1,15 @@
|
|
|
<!DOCTYPE html>
|
|
|
-<html lang="en">
|
|
|
+<html>
|
|
|
<head>
|
|
|
- <meta charset="UTF-8">
|
|
|
- <title>Title</title>
|
|
|
- <style>
|
|
|
- body{
|
|
|
- background: #00FFFF;
|
|
|
- }
|
|
|
- </style>
|
|
|
+ <title>Page Swipe</title>
|
|
|
+ <script src="jquery.js"></script>
|
|
|
+<!-- 支持中文-->
|
|
|
+ <meta charset="utf-8">
|
|
|
+
|
|
|
</head>
|
|
|
<body>
|
|
|
-<!--下载按钮-->
|
|
|
-<button onclick="downloadDivContent('#test123')">下载</button>
|
|
|
-<div id="test123">
|
|
|
- <h1>测试</h1>
|
|
|
- <p>测试内容</p>
|
|
|
+<div>
|
|
|
+ $2$的平方是指$2$乘以$2$。\n\n解答过程如下:\n\n$2\\times2$ $=4$所以,$2$的平方等于$4$。
|
|
|
</div>
|
|
|
-<script>
|
|
|
- function downloadDivContent(selector) {
|
|
|
- // 获取目标div的内容
|
|
|
- var targetDiv = document.querySelector(selector).innerHTML;
|
|
|
-
|
|
|
- // 创建Blob对象
|
|
|
- var blob = new Blob([targetDiv], { type: 'text/html' });
|
|
|
-
|
|
|
- // 创建下载链接
|
|
|
- var downloadLink = document.createElement('a');
|
|
|
- downloadLink.href = URL.createObjectURL(blob);
|
|
|
-
|
|
|
- // 设置下载链接的属性
|
|
|
- downloadLink.download = 'div_content.html'; // 设置文件名
|
|
|
- downloadLink.style.display = 'none'; // 隐藏下载链接
|
|
|
-
|
|
|
- // 将下载链接添加到页面中
|
|
|
- document.body.appendChild(downloadLink);
|
|
|
-
|
|
|
- // 模拟用户点击下载链接
|
|
|
- downloadLink.click();
|
|
|
-
|
|
|
- // 清理下载链接
|
|
|
- document.body.removeChild(downloadLink);
|
|
|
- }
|
|
|
-</script>
|
|
|
</body>
|
|
|
</html>
|