js中点击按钮将html页面导出成图片

2024-11-05 百科 86阅读 投稿:情痴

1. js中点击按钮将html页面导出成图片

一、添加引用在解决方案上单击右键,选择“Add Reference。”

添加“System.Windows.Forms”,添加完后,Web.Config 中应该有类似下面的内容:二、设置 STA 模式在 @ Page 指令中加上 AspCompat="true",以强制该网页在 STA(单线程单元) 模式下执行。结果类似如下:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" AspCompat="true" %>三、写截图代码using System;using System.Collections;using System.Configuration;using System.Data;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Drawing;using System.Drawing.Imaging;using System.Windows.Forms;public partial class _Default : System.Web.UI.Page{private WebBrowser _webBrowser;protected void Page_Load(object sender, EventArgs e){string url = Request.QueryString["url"];if (string.IsNullOrEmpty(url)){url = ">

<head>

<script type="text/javascript">

var count=0;

function Change(){

count++;

if(count>18){

count=1;

}

i = document.getElementById("image");

j = document.getElementById("txt");

j.value="当前照片第"+count+"张";

if(count<10){

i.src="../../image/00"+count+".jpg";

}else{

i.src="../../image/0"+count+".jpg";

}

}

</script>

</head>

<body onl oad="Change();">

<p>;点击图片,切换到下一张,最后一张的下一张是第一张</p>

<p><input id="txt" type="text" /></p>

<div>

<img id="image" name="image" src="" onclick="Change();" />

</div>

</body>

</html>

js怎么把网页转成

声明:沿途百知所有(内容)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系我们将尽快删除