I have some JavaScript in a page that takes the values passed by a module Window and assigns it to a C# variable, so it can be used within the code behind. So my JavaScript looks like:
The 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>
And to clarify this a bit more. The Module window is pulling in a page from localhost, but the Module window is being called from a page on localhost:61156. So once the javascript sets the variavle it also issues a click command on a asp.net button to run some code:
C# Code
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;
}
}
So when I run this I get a javascript error that says:
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
So is there any possible way around this or way to fix this? I've been scratching my head for two days and I'm ready to throw my keyboard. :) Thanks!
SecurePaymentand funny that even javascript itself complains about "unsafe JavaScript" ;-)