Reputation: 1643
I have a script in which I am trying to open a child window and disable a parent window and re-enable the parent once the child window is closed as shown below:
function OpenChild() {
lockOpportunity();
if (ClinicalDataWindow == null || ClinicalDataWindow.closed) {
ClinicalDataWindow = window.open(clinicalDataUrl, 'EditOppClinicalData', GetWindowOptions(1020, 600), true);
var unloadFunc = function () { unlockOpportunity(); };
if (ClinicalDataWindow) {
if (ClinicalDataWindow.addEventListener) {
ClinicalDataWindow.addEventListener('unload', unloadFunc, false);
}
else {
ClinicalDataWindow.attachEvent('onunload', unloadFunc);
}
}
}
else {
ClinicalDataWindow.focus();
}
return false;
}
function lockOpportunity() {
$('#overlay').addClass('locking-overlay');
$('#overlay').height($(".t-edit-form-container").height());
$('#overlay').show();
}
function unlockOpportunity() {
$('#overlay').removeClass('locking-overlay');
$('#overlay').hide();
}
Below is the div which i am converting to an overlay to lock the parent
<div id="overlay" style="display:none;"></div>
and the CSS:
.locking-overlay
{
position: absolute;
width:930px;
@*height: 700px;*@
z-index: 1000;
background-color: black;
opacity: 0.5;
filter: alpha(opacity=50);
}
Every works perfectly on my local machine. BUt when I run this code on the server I am getting Script error "Access is denied" error. The child window is in the same domain and I am using IIS7.
EDIT: The script code is in an external js file.
Upvotes: 1
Views: 2218
Reputation: 6141
Does your clinicalDataUrl follow the Same Origin Policy? Which means you can open a new window on whichever url you want but to interact with it you need to be in the same domain, protocol and port from where you try to interact.
EDIT: here is what i mean in my 2nd comment
$(function(){
$(window).on('unlockOpportunityEvent',unlockOpportunity);
});
function OpenChild() {
lockOpportunity();
var origin = window;
if (ClinicalDataWindow == null || ClinicalDataWindow.closed) {
ClinicalDataWindow = window.open(clinicalDataUrl, 'EditOppClinicalData', GetWindowOptions(1020, 600), true);
var unloadFunc = function () { $(origin).trigger('unlockOpportunityEvent'); };
if (ClinicalDataWindow) {
if (ClinicalDataWindow.addEventListener) {
ClinicalDataWindow.addEventListener('unload', unloadFunc, false);
}
else {
ClinicalDataWindow.attachEvent('onunload', unloadFunc);
}
}
}
else {
ClinicalDataWindow.focus();
}
return false;
}
function lockOpportunity() {
$('#overlay').addClass('locking-overlay');
$('#overlay').height($(".t-edit-form-container").height());
$('#overlay').show();
}
function unlockOpportunity() {
$('#overlay').removeClass('locking-overlay');
$('#overlay').hide();
}
Upvotes: 1