西安手机网站案例,网站排名影响因素,营销渠道有哪些,网站关键词优化技巧1两窗口之间存在着关系.父窗口parent.htm打开子窗口son.htm子窗口可以通过window.opener指向父窗口.这样可以访问父窗口的对象. 优点:取值方便.只要window.opener指向父窗口,就可以访问所有对象. 不仅可以访问值,还可以访问父窗口的方法.值长度无限制.缺点:两窗口要存在着… 1两窗口之间存在着关系.父窗口parent.htm打开子窗口son.htm子窗口可以通过window.opener指向父窗口.这样可以访问父窗口的对象. 优点:取值方便.只要window.opener指向父窗口,就可以访问所有对象. 不仅可以访问值,还可以访问父窗口的方法.值长度无限制.缺点:两窗口要存在着关系.就是利用window.open打开的窗口.不能跨域. Post.htm input typetext namemaintextinput typebutton οnclickwindow.open(Read.htm) valueOpen Read.htm script languagejavascript //window.open打开的窗口.//利用opener指向父窗口.var parentText window.opener.document.all.maintext.value;alert(parentText);/script 2利用Cookie.Session.Application Cookie是浏览器存储少量命名数据.它与某个特定的网页或网站关联在一起.Cookie用来给浏览器提供内存,以便脚本和服务器程序可以在一个页面中使用另一个页面的输入数据. 优点:可以在同源内的任意网页内访问.生命期可以设置.缺点:值长度有限制. Post.htm input typetext nametxt1input typebutton οnclicksetCookie(baobao,document.all.txt1.value) valuePostscript languagejavascript function setCookie(name,value){/* *--------------- setCookie(name,value) ----------------- * setCookie(name,value) * 功能:设置得变量name的值 * 参数:name,字符串;value,字符串. * 实例:setCookie(username,baobao) * update:2004-6-11 10:30 *--------------- setCookie(name,value) ----------------- */ var Days 30; //此 cookie 将被保存 30 天 var exp new Date(); exp.setTime(exp.getTime() Days*24*60*60*1000); document.cookie name escape (value) ;expires exp.toGMTString(); location.href Read.htm; //接收页面.}/script Read.htm script languagejavascript function getCookie(name){/* *--------------- getCookie(name) ----------------- * getCookie(name) * 功能:取得变量name的值 * 参数:name,字符串. * 实例:alert(getCookie(baobao)); * update:2004-6-11 10:30 *--------------- getCookie(name) ----------------- */ var arr document.cookie.match(new RegExp((^| )name([^;]*)(;|$))); if(arr !null) return unescape(arr[2]); return null;}alert(getCookie(baobao));/script 3URL篇 能过URL进行传值.把要传递的信息接在URL上. 优点:取值方便.可以跨域.缺点:值长度有限制. Post.htm input typetext nameusernameinput typetext namesexinput typebutton οnclickPost() valuePostscript languagejavascript function Post(){ //单个值 Read.htm?usernamebaobao; //多全值 Read.htm?usernamebaobaosexmale; url Read.htm?usernameescape(document.all.username.value); url sex escape(document.all.sex.value); location.hrefurl;}/script Read.htm script languagejavascript /* *--------------- Read.htm ----------------- * Request[key] * 功能:实现ASP的取得URL字符串,Request(AAA) * 参数:key,字符串. * 实例:alert(Request[AAA]) * author:wanghr100(灰豆宝宝.net) * update:2004-6-11 10:30 *--------------- Request.htm ----------------- */var urllocation.search;var Request new Object();if(url.indexOf(?)!-1){ var str url.substr(1) //去掉?号 strs str.split(); for(var i0;istrs.length;i) { Request[strs[i].split()[0]]unescape(strs[i].split()[1]); }}alert(Request[username])alert(Request[sex])/script转载自http://blog.csdn.net/wanghr100/archive/2004/07/01/PostValue.aspx 四、使用Server.Transfer 虽然这种方法有点复杂但也不失为一种在页面传值的方式。 举个例子看看 1、创建一个web form 2、在新建的web form中放置一个button1在放置两个TextBox1,TextBox2 3、为button按钮创建click事件 代码如下 private void Button1_Click (object sender, System.EventArgs e) { Server.Transfer(webform2.aspx); } 4、创建过程来返回TextBox1,TextBox2控件的值代码如下 public string Name { get { return TextBox1.Text; } } public string EMail { get { return TextBox2.Text; } } 5、新建一个目标页面命名为webform2 6、在webform2中放置两个Label1,Label2 在webform2的Page_Load中添加如下代码 private void Page_Load (object sender, System.EventArgs e) { //创建原始窗体的实例 WebForm1 wf1; //获得实例化的句柄 wf1(WebForm1)Context.Handler; Label1.Textwf1.Name; Label2.Textwf1.EMail; } 运行,即可看到传递后的结果了。祥解ASP.NET Server.Transfer()是在两个页面之间进行传值的好方法从A页面Transfer到B页面时就可以在B页面通过Context.Handler获得A页面的一个类的实例从而在B调用A的各个成员对象。 下面的示例建立了WebForm1和WebForm2通过Server.Transfer()方法演示在WebForm2中读取WebForm1的文本框、读取属性、通过Context传值、调用WebForm1的方法等 WebForm1上放置一个TextBox1和一个Button1程序如下: public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.WebControls.TextBox TextBox1; protected System.Web.UI.WebControls.Button Button1; private void Page_Load(object sender, System.EventArgs e) { Context.Items.Add(Context,Context from Form1); } public string Time { get{return DateTime.Now.ToString();} } public string TestFun() { return Function of WebForm1 Called; } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); } private void InitializeComponent() { this.Button1.Click new System.EventHandler(this.Button1_Click); this.Load new System.EventHandler(this.Page_Load); } #endregion private void Button1_Click(object sender, System.EventArgs e) { Server.Transfer(WebForm2.aspx, true); } 在WebForm2上放置一个Literal1控件程序如下 public class WebForm2 : System.Web.UI.Page { protected System.Web.UI.WebControls.Literal Literal1; private void Page_Load(object sender, System.EventArgs e) { string strTxt; WebForm1 oForm(WebForm1)this.Context.Handler; strTxtValue of Textbox:Request.Form[TextBox1] br; strTxtTime Property:oForm.Time br; strTxtContext String:Context.Items[Context].ToString() br; strTxtoForm.TestFun() br; Literal1.Text strTxt; } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); } private void InitializeComponent() { this.Load new System.EventHandler(this.Page_Load); } #endregion } 补充说明就是Transfer方法的第二个参数指示是否保留页面的Form和QuerryString的值你可以试着把它设为False则在WebForm2中将读不到TextBox1的值。