-3

Help me pleaz

let discordLogo = document.createElement("img");
discordLogo.setAttribute(
  "src",
  "https://media.discordapp.net/attachments/1079211646746099792/1079217653916377148/discord.png?width=470&height=470"
);
discordLogo.style.width = "40px";
discordLogo.style.height = "40px";
discordLogo.style.position = "absolute";
discordLogo.style.top = "14px";
discordLogo.setAttribute("id", "discordInv");
discordLogo.style.right = "75px";
main.appendChild(discordLogo);

document.querySelector("#discordInv").addEventListener("click", () => {
  window.location.href = ("https://discord.gg/52BTDY"); // THIS WORKS BUT IT WON'T TARGET "_BLANK" OR WHATEVER PLEASE HELP
});

was expecting it to work and open the discord invite in another tab

1 Answers1

0

Just use

window.open("https://discord.gg/52BTDY");

instead of

window.location.href = ("https://discord.gg/52BTDY");

This opens your link in a new tab, and is similar to the

target = "_blank"

property in CSS.

2539901
  • 3
  • 3