From 457f03798c69f2053894d9971d4b187521c0d9ad Mon Sep 17 00:00:00 2001 From: BurningTreeC Date: Tue, 6 Nov 2018 14:54:00 +0100 Subject: [PATCH] Fix error opening new windows with popup-blocker (#3515) this prevents errors when a popup blocker blocks opening a new window from within a running TW --- core/modules/startup/windows.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/modules/startup/windows.js b/core/modules/startup/windows.js index fbaccccc3..591f5d5fa 100644 --- a/core/modules/startup/windows.js +++ b/core/modules/startup/windows.js @@ -33,8 +33,16 @@ exports.startup = function() { height = paramObject.height || "600", variables = $tw.utils.extend({},paramObject,{currentTiddler: title}); // Open the window - var srcWindow = window.open("","external-" + title,"scrollbars,width=" + width + ",height=" + height), + var srcWindow, + srcDocument; + // In case that popup blockers deny opening a new window + try { + srcWindow = window.open("","external-" + title,"scrollbars,width=" + width + ",height=" + height), srcDocument = srcWindow.document; + } + catch(e) { + return; + } windows[title] = srcWindow; // Check for reopening the same window if(srcWindow.haveInitialisedWindow) {