利用javascript 在一个html页面中按照FORM方式设定其它页面的值 。

    技术2022-07-03  113

     1.aspx

     

     

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default12.aspx.cs" Inherits="Default12" %>

    <!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>无标题页</title>    <script type="text/javascript">function ff(){    window.open("default13.aspx");}

    </script>    </head><body>    <form id="form1" runat="server">    <div>        <br />        <input id="Text1" type="text" /><br />        <input type="button" value="Open Window" οnclick="ff()" />

        </div>    </form></body></html>

     

     

    default13.aspx

     

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default13.aspx.cs" Inherits="Default13" %>

    <!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>无标题页</title>

    <script type="text/javascript">        function ff()    {        self.opener.document.getElementById("Text1").value=document.getElementById("TextBox1").value;    }

    </script>        </head><body>    <script type="text/javascript">   //          self.opener.document.write("default13.aspx");    //      alert(self.opener);        var ss=self.opener;        if (ss=="[object]" )        {            self.opener.document.getElementById("Text1").value="12345";         }

        </script>

        <form id="form1" runat="server">    <div>        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></div>        <input id="Button2" type="button" value="button" οnclick="ff()" />    </form></body></html>

     

     

    default13.aspx.cs

     

     

    using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;

    public partial class Default13 : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {

        }    protected void Button1_Click(object sender, EventArgs e)    {        TextBox1.Text = "设定值";    }}


    最新回复(0)