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) => {