Search code examples
javascriptsilverlightpopupdom-eventshtmlbridge

Notification when popup is closed using Silverlight's HtmlPage.PopupWindow()


I am popping up an HTML page from a Silverlight application using the HtmlPage.PopupWindow() method. I am trying to handle the event of when the popup window is closed from within Silverlight. This is how I am attempting to do this:

 var window = HtmlPage.PopupWindow(new Uri("http://mypopup..."), "popup", options);

 EventHandler<HtmlEventArgs> windowClosed = (sender, e) =>
 {
     // would like to refresh the page when popup is closed...
     HtmlPage.Document.Submit();
 };

 window.AttachEvent("onUnload", windowClosed);

However the event handler never seems to get called. Is this something that is possible or am I missing something?

The Silverlight app and the HTML popup page are on the same domain, however they are actually on different ports. I was thinking that maybe the pages being on different ports would be considered a cross-site restriction and cause the JavaScript to fail.


Solution

  • You are correct, the variation in port number is enough to prevent Silverlight from accessing events and content of the popup window.