I am building a custom linktree and Im struggling to find the right command to open these links in a new tab. Currently links are opened in current window as well as in a new tab.
let url = document.createElement('url');
switch(event.target.innerText) {
case 'youtube' : url = 'https://www.youtube.com/';break;
case 'spotify' : url = 'https://open.spotify.com/artist/';break;
case 'applemusic' : url = 'https://music.apple.com/';break;
case 'soundcloud' : url = 'https://soundcloud.com/';break;
case 'amazon' : url = 'https://media.giphy.com/';break;
default: break;
}
if(url) {window.open(top.location.href = url, '_blank');}
When I replace top with window for the last line, like this:
if(url) {window.open(top.location.href = url, '_blank');}
it opens the url in a weird box inside my current window.
On a sidetone this is my first post, so please tell me in case I did something wrong.