照着网上说的方法,怎么最后就根本没执行前台的js脚本呢
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="exportWord.aspx.cs" Inherits="exportWord" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        .iframeCss{ width:0; height:0;}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        <iframe id="editor" src="about:blank" visible="false" class="iframeCss"></iframe>
        <table id="table1">
            <tr>
                <td>
                    <asp:DropDownList ID="DropDownList1" runat="server">
                        <asp:ListItem Value="111111111111">111111111111</asp:ListItem>
                        <asp:ListItem>222222</asp:ListItem>
                    </asp:DropDownList>
                    <asp:Label ID="Label1" runat="server" Text="Label" Visible="false"></asp:Label>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
<script type="text/javascript" language="javascript">
function CopyTable()
{
CopyHtmlElement(table1)
}function CopyHtmlElement(obj)
{
document.getElementById( "editor").width=0; editor.document.designMode = 'On'; // 将iframe变成可编辑模式,即HTML编辑器
editor.document.write("<body></body>"); // 初始化编辑器
editor.document.body.innerHTML = obj.outerHTML;
editor.document.body.createTextRange().select(); // 选中编辑器内所有内容
editor.document.execCommand("copy","",null); // 复制
}</script>protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = DropDownList1.SelectedValue.ToString();
        Label1.Visible = true;
        DropDownList1.Visible = false;
        ClientScript.RegisterStartupScript(Page.GetType(), "", "CopyTable()true);
        string fileName = "测试数据";
        ExportWord(fileName);

解决方案 »

  1.   

    RegisterStartupScript 不叫做“后台执行”,它只是输出一个字符串插入给浏览器端的html字符串中。如果你遇到某个网页上叫做“后台执行”,那么这种网页还能看?!
      

  2.   

    "CopyTable()true) 这样写肯定有问题
      

  3.   

    以前是这样的,上面已经编辑不了了
    ClientScript.RegisterStartupScript(Page.GetType(), "", "CopyTable();", true);
      

  4.   

    ClientScript.RegisterStartupScript(Page.GetType(), "", "CopyTable();", true);//把红色的地方换成你的JS实现代码试下应该没问题!