开发者

Redirect Parent Form when ShowModalDialog closed

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜