我在页面中有一些 JavaScript,它获取模块 Window 传递的值并将其分配给 C# 变量,因此可以在后面的代码中使用它。所以我的 JavaScript 看起来像:
JavaScript
<script type="text/javascript">
function openSecure(args) {
var manager = $find("<%= rwmSecure.ClientID %>");
var domain = '<%=ConfigurationManager.AppSettings("CPCDomain").ToString %>';
var URL;
if (domain == 'localhost') {
URL = 'http://localhost';
}
URL += "/WindowPage.aspx?args=" + args;
manager.open(URL, "rwSecure");
}
function OnClientCloseSecure(oWnd, args) {
var arg = args.get_argument();
if (arg) {
var ResultCode = arg.ResultCode;
document.getElementById("hdnResultCode").value = ResultCode;
var AuthCode = arg.AuthCode;
var ReferenceNumber = arg.ReferenceNumber;
var TransactionID = arg.TransactionID;
var ErrorCode = arg.ErrorCode;
var ErrorDescription = arg.ErrorDescription;
var CardNumber = arg.CardNumber;
var PONumber = arg.PONumber;
//document.getElementById('<%=btn.ClientID %>').click();
__doPostBack('pnlComplete', '');
}
}
</script>
并进一步澄清这一点。Module 窗口正在从 localhost 中拉入一个页面,但 Module 窗口是从 localhost:61156 上的页面调用的。因此,一旦 javascript 设置了 variavle,它还会在 asp.net 按钮上发出一个单击命令来运行一些代码:
C# 代码
protected void btn_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(hdnResultCode.Value)) {
dspConfirm();
pnlComplete.Visible = false;
pnlConfirm.Visible = true;
} else {
dspComplete();
pnlComplete.Visible = true;
pnlConfirm.Visible = false;
}
}
所以当我运行它时,我得到一个 javascript 错误,上面写着:
Unsafe JavaScript attempt to access frame with URL http://localhost/SecurePayment.aspx?args=H4sIAAAAAAAEAOy9B2AcSZYlJi9tynt%2fSvVK1%2bB0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcplVmVdZhZAzO2dvPfee%2b%2b999577733ujudTif33%2f8%2fXGZkAWz2zkrayZ4hgKrIHz9%2bfB8%2fIr578jMnL09%2b5k3etG%2fqbNlk07aolj%2bzi%2bdndsY7u%2f9PAAAA%2f%2f8VkT5ZIQAAAA%3d%3d&rwndrnd=0.23641548841260374 from frame with URL http://localhost:65116/ShoppingCart.aspx. Domains, protocols and ports must match.
b.RadWindow._registerChildPageHandlersScriptResource.axd?d=vMihE91hOtu6KBE47c3D9AjqD9Il5YI4LpCLhSvp5YZn6p98cl2a_AbJJmNWVZfnmjtLnCnYEoaBHBC919OsikIEmKq8TGOzWNWN_HUBLLo8fW7DdN4EuN3Q076lAa_FOwh_Yk2b3DL-W2Fv0&t=38ec0598:1125
b.RadWindow._onIframeLoadScriptResource.axd?d=vMihE91hOtu6KBE47c3D9AjqD9Il5YI4LpCLhSvp5YZn6p98cl2a_AbJJmNWVZfnmjtLnCnYEoaBHBC919OsikIEmKq8TGOzWNWN_HUBLLo8fW7DdN4EuN3Q076lAa_FOwh_Yk2b3DL-W2Fv0&t=38ec0598:1143
(anonymous function)ScriptResource.axd:47
Sys$UI$DomEvent$addHandler.browserHandlerScriptResource.axd:4048
那么有没有办法解决这个问题或解决这个问题?这两天我一直在挠头,我准备扔键盘了。:) 谢谢!