diff --git a/javascript/tokenscript-viewer/src/components/common/card-view/card-modal.tsx b/javascript/tokenscript-viewer/src/components/common/card-view/card-modal.tsx index 49f172ff..d38e9921 100644 --- a/javascript/tokenscript-viewer/src/components/common/card-view/card-modal.tsx +++ b/javascript/tokenscript-viewer/src/components/common/card-view/card-modal.tsx @@ -49,7 +49,7 @@ export class CardModal { return ( diff --git a/javascript/tokenscript-viewer/src/components/common/card-view/card-popover.tsx b/javascript/tokenscript-viewer/src/components/common/card-view/card-popover.tsx index 44e27269..2a7cac06 100644 --- a/javascript/tokenscript-viewer/src/components/common/card-view/card-popover.tsx +++ b/javascript/tokenscript-viewer/src/components/common/card-view/card-popover.tsx @@ -136,8 +136,8 @@ export class CardPopover implements IViewBinding { async unloadTokenView() { await this.dialog.closeDialog(); this.currentCard = null; - this.iframe.src = ""; - document.location.hash = "#"; + this.iframe.contentWindow.location.replace(""); + history.replaceState(undefined, undefined, "/"); } viewError(error: Error) { diff --git a/javascript/tokenscript-viewer/src/components/common/tokens-grid/tokens-grid.tsx b/javascript/tokenscript-viewer/src/components/common/tokens-grid/tokens-grid.tsx index f91436bf..eb7767f7 100644 --- a/javascript/tokenscript-viewer/src/components/common/tokens-grid/tokens-grid.tsx +++ b/javascript/tokenscript-viewer/src/components/common/tokens-grid/tokens-grid.tsx @@ -144,7 +144,7 @@ export class TokensGrid { // TODO: Remove index - all cards should have a unique name but some current tokenscripts don't match the schema // TODO: set only card param rather than updating the whole hash query if (card.view) - document.location.hash = "#card=" + (card.name ?? cardIndex); + history.replaceState(undefined, undefined, "#card=" + (card.name ?? cardIndex)); } render() { diff --git a/javascript/tokenscript-viewer/src/components/viewers/new/new-viewer.tsx b/javascript/tokenscript-viewer/src/components/viewers/new/new-viewer.tsx index bc079ee5..bbd7cc01 100644 --- a/javascript/tokenscript-viewer/src/components/viewers/new/new-viewer.tsx +++ b/javascript/tokenscript-viewer/src/components/viewers/new/new-viewer.tsx @@ -72,7 +72,7 @@ export class NewViewer { // Import completed successfully, add tokenscript to myTokenScripts tsMeta = await this.addFormSubmit("url", {tsId: tokenScript.getSourceInfo().tsId, image: definition.meta.image}); - document.location.hash = ""; + //document.location.hash = ""; window.history.replaceState({}, document.title, "/"); this.showToast.emit({ diff --git a/javascript/tokenscript-viewer/src/integration/abstractViewBinding.ts b/javascript/tokenscript-viewer/src/integration/abstractViewBinding.ts index 0960ffdc..2e422cc9 100644 --- a/javascript/tokenscript-viewer/src/integration/abstractViewBinding.ts +++ b/javascript/tokenscript-viewer/src/integration/abstractViewBinding.ts @@ -53,9 +53,9 @@ export abstract class AbstractViewBinding implements IViewBinding { async unloadTokenView() { this.currentCard = null; - this.iframe.src = ""; this.actionBar.style.display = "none"; - document.location.hash = "#"; + this.iframe.contentWindow.location.replace(""); + history.replaceState(undefined, undefined, "/"); } protected showLoader() { @@ -75,7 +75,8 @@ export abstract class AbstractViewBinding implements IViewBinding { if (card.isUrlView) { - iframe.src = card.url; + //iframe.src = card.url; + iframe.contentWindow.location.replace(card.url); } else { const html = await card.renderViewHtml(); @@ -84,7 +85,8 @@ export abstract class AbstractViewBinding implements IViewBinding { const urlFragment = card.urlFragment; - iframe.src = URL.createObjectURL(blob) + (urlFragment ? "#" + urlFragment : ""); + const url = URL.createObjectURL(blob) + (urlFragment ? "#" + urlFragment : ""); + iframe.contentWindow.location.replace(url); // TODO: try src-doc method }