mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Fix #2033: Rstudio Viewer window not closed on shiny::stopApp()
This commit is contained in:
@@ -141,30 +141,8 @@ var ShinyApp = function() {
|
||||
};
|
||||
|
||||
this.$notifyDisconnected = function() {
|
||||
|
||||
// function to normalize hostnames
|
||||
var normalize = function(hostname) {
|
||||
if (hostname === "127.0.0.1")
|
||||
return "localhost";
|
||||
else
|
||||
return hostname;
|
||||
};
|
||||
|
||||
// Send a 'disconnected' message to parent if we are on the same domin
|
||||
var parentUrl = (parent !== window) ? document.referrer : null;
|
||||
if (parentUrl) {
|
||||
// parse the parent href
|
||||
var a = document.createElement('a');
|
||||
a.href = parentUrl;
|
||||
|
||||
// post the disconnected message if the hostnames are the same
|
||||
if (normalize(a.hostname) === normalize(window.location.hostname)) {
|
||||
var protocol = a.protocol.replace(':',''); // browser compatability
|
||||
var origin = protocol + '://' + a.hostname;
|
||||
if (a.port)
|
||||
origin = origin + ':' + a.port;
|
||||
parent.postMessage('disconnected', origin);
|
||||
}
|
||||
if (window.parent) {
|
||||
window.parent.postMessage("disconnected", "*");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user