Home > front end >  Open other webiste in new tab alogn with my website
Open other webiste in new tab alogn with my website

Time:05-15

I have a website-1 (www.example.com). When a customer reaches out to my website, the other website-2 (www.example2.com) should be open in a new tab corresponding with the website (www.example.com). How to do this

CodePudding user response:

You can do an <a> element with the target="_blank" attribute.

Like so:

<a href="http://www.example2.com" target="_blank">Example 2</a>

If you want them both to load, then you can make it go to the second one in another tab with javascript using the window.onload event.

Like so:

window.onload = function() {
window.open(url, '_blank').focus();
};

CodePudding user response:

I would like to add to Daan Teppema's answer.

Add rel property in the tag, if the website is not safe or untrusted add noopener. but if you are directing within your website remove the noreferrer for SEO tracking purposes.

<a href="http://www.example2.com" target="_blank" rel="noreferrer noopener">Example 2</a>

This will keep your website tab open and in the meantime open a new tab with the link you've provided.

  • Related