mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-04-25 07:57:18 +08:00
14 lines
457 B
TypeScript
14 lines
457 B
TypeScript
export const openLink = <T>(link: T): void => {
|
|
const $a: HTMLElement = document.createElement("a");
|
|
// @ts-expect-error
|
|
$a.setAttribute("href", link);
|
|
$a.setAttribute("target", "_blank");
|
|
$a.setAttribute("rel", "noreferrer noopener");
|
|
$a.setAttribute("id", "external");
|
|
document.getElementById("external") &&
|
|
document.body.removeChild(document.getElementById("external"));
|
|
document.body.appendChild($a);
|
|
$a.click();
|
|
$a.remove();
|
|
};
|