rick roll in typescript

To rick roll someone using Typescript, we can create a button on a webpage and add a click event listener to it. When the button is clicked, it will redirect the user to the infamous Rick Astley's "Never Gonna Give You Up" music video.

Here's the code:

index.ts
const button = document.getElementById("rick-roll-button");

button.addEventListener("click", () => {
  window.location.href = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
});
178 chars
6 lines

In the above code, we get a reference to an HTML element with an id of "rick-roll-button". We then add a click event listener to it and when clicked, we set the window location href to the link of the video.

Make sure to add the HTML button to your web page and include this script on the same page. When the user clicks the button, they will be redirected to the Rick Astley video, hence the prank!

gistlibby LogSnag