diff --git a/www/js/app.js b/www/js/app.js
index 3c4a887f..00ad7b32 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -2138,6 +2138,10 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'images', 'cookies', 'q', 'trans
iframeArticleContent.contentWindow.onunload = function () {
$("#searchingArticles").show();
};
+ if (params.allowHTMLExtraction) {
+ var determinedTheme = params.cssTheme == 'auto' ? cssUIThemeGetOrSet('auto') : params.cssTheme;
+ uiUtil.insertBreakoutLink(determinedTheme);
+ }
};
iframeArticleContent.src = '../' + dirEntry.namespace + "/" + encodeURIComponent(dirEntry.url);
// Display the iframe content
diff --git a/www/js/lib/uiUtil.js b/www/js/lib/uiUtil.js
index db0b8d70..d71cd9c8 100644
--- a/www/js/lib/uiUtil.js
+++ b/www/js/lib/uiUtil.js
@@ -357,13 +357,12 @@ define(['util'], function(util) {
function insertBreakoutLink(mode) {
var desc = "Open article in new tab or window";
var iframe = document.getElementById('articleContent').contentDocument;
- // This code provides an absolute link - keep for reference. Removes the file and any query string from href
- // var prefix = window.location.href.replace(/^((?!.*\?).*\/|.*\/(?=[^\/]*\?)).*$/, '$1');
- // But in Kiwix JS Windows, we can easily get the relative path of the current document:
+ // This code provides an absolute link, removing the file and any query string from href (we need this because of SW mode)
+ var prefix = window.location.href.replace(/^((?!.*\?).*\/|.*\/(?=[^\/]*\?)).*$/, '$1');
var div = document.createElement('div');
div.style.cssText = 'top: 10px; right: 25px; position: relative; z-index: 2; float: right;';
div.id = "openInTab";
- div.innerHTML = '
';
+ div.innerHTML = '
';
iframe.body.insertBefore(div, iframe.body.firstChild);
var openInTab = iframe.getElementById('openInTab');
// Have to use jQuery here becasue e.preventDefault is not working properly in some browsers