使用window.open向新页面传参

来源:互联网 发布:喷水织机配件淘宝网 编辑:程序博客网 时间:2024/05/29 09:41

 方法一:使用Javascript语言在客户端传递
/**********NO.1**********/
parent.aspx
<script>
  var obj = new Object();
  obj.name="51js";
  window.showModalDialog("modal.aspx",obj,"dialogWidth=200px;dialogHeight=100px");
</script>
modal.aspx
<script>
  var obj = window.dialogArguments
  alert("您传递的参数为:" + obj.name)
</script>
/**********NO.2**********/
parent.aspx
<script>
    var str=document.getElementById("Button1").id;
    window.open ('Attribute.aspx?id='+str, 'newwindow', 'height=300, width=400, top=50,left=50,     toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
</script>
modal.aspx
后台代码
    string id = Request.QueryString["id"].ToString();
    Response.Write("<script>alert('"+id.ToString()+"');</script>");


方法二:使用c#语言在服务器段传递
parent.aspx
    Response.Write("<Script>window.open ('Attribute.aspx?id=" + lbtnButton.ID + "','newwindow','height=300, width=400, top=50,left=50, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')</Script>");
modal.aspx
    string id = Request.QueryString["id"].ToString();
    Response.Write("<script>alert('"+id.ToString()+"');</script>");

 

 


 

原创粉丝点击