开发者

Redirect Parent Form when ShowModalDialog closed

开发者 https://www.devze.com 2023-03-07 18:22 出处:网络
How can I redirect my main page to another webpage when I close the modaldialog box using showModalDialog?

How can I redirect my main page to another webpage when I close the modaldialog box using showModalDialog?

I have here my code on closing the form:

function Msg() 
{ 
    parent.window.opener.location.href = 'MyRequirements.aspx'; 
    window.close();  
} 

Here's my code for opening the modal dialog box:

function Go()
{
    var model= document.getElementById("cboModel").value;
    var variant= document.getElementById("cboVariant").value;
    var color = document.getElementById("cboColor").value;
    var code = document.getElementById("txtCode").value;
    window.showModalDialog("MesgeBox.aspx?model=" + model +
        "&variant=" + variant + "&color=" + color + "&code=" + code +
        "","","dialogHeight: 100px; dialogWidth: 80px; edge: Raised;help: No; resizable: No; status: No; center: Yes开发者_运维技巧; scrollbars: No;")
}

The opener.location is not working.


It's been a long while since I used showModalDialog, but assuming the URL you want to redirect to is variable and needs to be set from the child modal dialog I think something like this should work:

// Msg() is on child dialog
function Msg()  {
    window.returnValue = 'MyRequirements.aspx';
    window.close();
}

// Go() is on parent window
function Go() {
   // your intialisation
   var newLocation = window.showModalDialog(/*your params*/);
   if (newLocation != "")
      window.location.href = newLocation;
} 

For more info see the online doco for returnValue and showModalDialog().

0

精彩评论

暂无评论...
验证码 换一张
取 消