From c01d79798315a2bae55a30c7a2cdfe9967b1d2e6 Mon Sep 17 00:00:00 2001 From: Xmader Date: Thu, 31 Dec 2020 14:08:00 -0500 Subject: [PATCH] fix: open url --- src/btn.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/btn.ts b/src/btn.ts index bcb603c..99ea967 100644 --- a/src/btn.ts +++ b/src/btn.ts @@ -192,17 +192,19 @@ export namespace BtnAction { else return url } - export const download = (url: UrlInput, fallback?: () => Promisable, timeout?: number): BtnAction => { + export const download = (url: UrlInput, fallback?: () => Promisable, timeout?: number, target?: '_blank'): BtnAction => { return process(async (): Promise => { const _url = await normalizeUrlInput(url) const a = document.createElement('a') a.href = _url - a.target = '_blank' + if (target) a.target = target a.dispatchEvent(new MouseEvent('click')) }, fallback, timeout) } - export const openUrl = download + export const openUrl = (url: UrlInput, fallback?: () => Promisable, timeout?: number): BtnAction => { + return download(url, fallback, timeout, '_blank') + } export const mscoreWindow = (scoreinfo: ScoreInfo, fn: (w: Window, score: WebMscore, processingTextEl: ChildNode) => any): BtnAction => { return async (btnName, btn, setText) => {