link.ts 431 B

123456789101112
  1. export const openLink = (link: string) => {
  2. const $a: HTMLElement = document.createElement("a");
  3. $a.setAttribute("href", link);
  4. $a.setAttribute("target", "_blank");
  5. $a.setAttribute("rel", "noreferrer noopener");
  6. $a.setAttribute("id", "external");
  7. document.getElementById("external") &&
  8. document.body.removeChild(document.getElementById("external"));
  9. document.body.appendChild($a);
  10. $a.click();
  11. $a.remove();
  12. };