您的位置:首页 > Web前端 > JavaScript

js new Open window vaule send and receive get Problem

2011-02-08 14:12 295 查看
<script>
function OpentryCustomer()
{

var Txttry = "<%= Txttry.ClientID %>";
var Hitry = "<%= Hitry.ClientID %>";
var Apppath = "http://localhost:58945/WebSite1/"
var url = Apppath+"CustomerDialog.aspx?Userid="+Hitry+"&UserName="+Txttry+"";
alert(url);
window.open(url,'newwindows1','height=1000, width=700, top=10, left=10, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
}
</script>

<div>
<asp:Button ID="BtnSearch" runat="server" Text="SearchTry" OnClientClick="OpentryCustomer()" />
<asp:Button ID="btnReSelectCustomer_Main" runat="server" CausesValidation="False" Visible="false"/>
<asp:TextBox ID="Txttry" runat="server" Text="" />
<asp:HiddenField ID="Hitry" runat="server" />
</div>

另一个页面,

<script>
/* request类 */
function request(strParame) {
var args = new Object( );
var query = location.search.substring(1);
var pairs = query.split("&"); // Break at ampersand
for(var i = 0; i < pairs.length; i++) {
var pos = pairs[i].indexOf('=');
if (pos == -1) continue;
var argname = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos+1);
value = decodeURIComponent(value);
args[argname] = value;
}
return args[strParame];
}
</script>
<script>
function SelectCustomer()
{
var userid = request('Userid');
alert(userid);
var username= request('UserName');
alert(username);

var customerID=document.getElementById("<%= TxtName.ClientID %>").value;
alert(customerID);
var customerName=document.getElementById("<%= TxtID.ClientID %>").value;
alert(customerName);
if(window.opener!=null)
{
var id = window.opener.document.getElementById(userid);
alert(id);
if(id!=null)
{
id.value = customerID;
}
var customerNamCtrl = window.opener.document.getElementById(username);
alert(customerNamCtrl);

if(customerNamCtrl!=null)
{
customerNamCtrl.value = customerName;
}

window.close();
}
return false;
}

</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Btn" runat="server" OnClientClick="SelectCustomer()" />
<asp:TextBox ID="TxtName" runat="server" Text="shabi"/>
<asp:TextBox ID="TxtID" runat="server" Text="shamao" />
</div>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: