rick roll in new tab in typescript

To rick roll in a new tab in TypeScript, assuming you have a button element in your HTML file with an ID of "rickroll-btn", you can add an event listener function that opens a new window when the button is clicked, and sets the URL of that window to the appropriate Rick Astley video link. Here's an example:

index.ts
const rickRollBtn = document.getElementById("rickroll-btn");

rickRollBtn.addEventListener("click", () => {
  window.open("https://www.youtube.com/watch?v=dQw4w9WgXcQ", "_blank");
});
184 chars
6 lines

In this example, window.open creates a new tab, and the link to the Rick Astley video is passed as the first parameter. The second parameter tells the function to open the link in a new tab, rather than the current tab. When the button is clicked, this code will execute and the user will be taken to the video, hopefully getting a good laugh out of it.

gistlibby LogSnag