How to force user to open in new tab?

Hi there! I found this piece of code in the Replit Badge code.

if (window.location.hostname.split('.')[1] === 'id') {
  return;
}

When a repl is opened in the covered page, the link must be something.id.repl.co where the something is the hash of this repl. The second segment would be a username instead of id if it’s opened in a new tab.

You can change the return part into other code that tell the user to go to a new page. I hope this can help you.

4 Likes

Hold up, @doxr, why did u do laugh reaction?

Thank you so much it worked!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.