From dd9e3b4864a127942e65c6297b6712fca2e4014c Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sat, 22 Feb 2014 05:19:50 +0000 Subject: [PATCH] Ensure top URL will change in case it wishes to react according to storagePrompt param (such as in the embedded editor). git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2722 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/extensions/ext-storage.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/editor/extensions/ext-storage.js b/editor/extensions/ext-storage.js index db56117e..adcffb74 100644 --- a/editor/extensions/ext-storage.js +++ b/editor/extensions/ext-storage.js @@ -48,13 +48,14 @@ svgEditor.addExtension('storage', function() { function replaceStoragePrompt (val) { val = val ? 'storagePrompt=' + val : ''; - if (window.location.href.indexOf('storagePrompt=') > -1) { - window.location.href = window.location.href.replace(/([&?])storagePrompt=[^&]*(&?)/, function (n0, n1, amp) { + var loc = top.location; // Allow this to work with the embedded editor as well + if (loc.href.indexOf('storagePrompt=') > -1) { + loc.href = loc.href.replace(/([&?])storagePrompt=[^&]*(&?)/, function (n0, n1, amp) { return (val ? n1 : '') + val + (!val && amp ? n1 : (amp || '')); }); } else { - window.location.href += (window.location.href.indexOf('?') > -1 ? '&' : '?') + val; + loc.href += (loc.href.indexOf('?') > -1 ? '&' : '?') + val; } } function setSVGContentStorage (val) {