From 0f2a845515cffc8e0df59ccc80b646984f4887d1 Mon Sep 17 00:00:00 2001 From: Kristoffer Gram Date: Tue, 1 Sep 2015 13:54:42 +0200 Subject: [PATCH] Copy base-tag to head If a base-tag is used, relative urls are unresolveable. Copy the tag to ensure the new document will resolve urls correctly for stylesheets and images. --- js/jquery.printarea.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/jquery.printarea.js b/js/jquery.printarea.js index 9713ea3..67467d2 100644 --- a/js/jquery.printarea.js +++ b/js/jquery.printarea.js @@ -91,9 +91,14 @@ return ''; }, getHead : function() { + var base = ""; var extraHead = ""; var links = ""; + if ($(document).find('head > base').length > 0) { + base += $(document).find('head > base')[0].outerHTML; + } + if ( settings.extraHead ) settings.extraHead.replace( /([^,]+)/g, function(m){ extraHead += m }); $(document).find("link") @@ -110,7 +115,7 @@ }); if ( settings.extraCss ) settings.extraCss.replace( /([^,\s]+)/g, function(m){ links += '' }); - return "" + settings.popTitle + "" + extraHead + links + ""; + return "" + settings.popTitle + "" + base + extraHead + links + ""; }, getBody : function ( elements ) { var htm = "";