用js获得父级页面元素
 
index1.html  有个textbox id=txt1index1.html 跳转到index2.html  需要在index2.html  获得textbox  txt1的值 不存在传参 因为index1.html 是别人的页面 不能改

解决方案 »

  1.   

    你不传参又想获取到另一个页面的值,Cookie可以不这个是获取Cookie的方法
    HttpContext.Current.Response.Cookies["txt1"].Value = "this.txt1.value";然后index2获取cookie,可以用cs获取然后赋值
    indext2.aspx.csRequest.Cookies["txt1"].Value = this.txt1.value;然后把这个值写入index2的隐藏域
    <input type="hidden" id="txt1" class="txt1" value="" runat="server" />或者用Jquery获取cookie值var txt1= $(".txt1").val();
    $.cookie('txt1', null); //在这个值读取完以后有必要清除下这个cookie,以免值乱套当然,$.cookie 这个你要下载对应jqeury插件,网上一搜就有
      

  2.   

    谢谢大哥回答的很详细,但是index1.html 这个页面是别人的页面 我不能做处理  就是想 有没获得来源页面元素的值的办法。
      

  3.   

    是获得不到的
    在前端只能存到cookie中 将来在cookie中获取
      

  4.   

    如果完全不改动index1.html页面的话,貌似实现不了。
    因为页面已经跳转了。
    如果是其他窗口打开的话,还可通过opener来取得。
      

  5.   

    获取父页面的值
    var s=top.document.getElementById("ID").value;
      

  6.   

    如果没有用框架,或者iframe,实现不了。
    var s=top.document.getElementById("ID").value;
    -------------
    如果不改动index1.html页面的话, 实现起来很困难。
    建议楼主改变思路。