How to open html page in new tab
There are several ways to open an HTML page in a new tab:
Method 1: Using the target
attribute
You can add the target
attribute to the <a>
tag and set its value to _blank
to open the link in a new tab:
<a rel="nofollow" target="_blank" href="your-html-page.html" target="_blank">Open in new tab</a>
Method 2: Using JavaScript
You can use JavaScript to open the HTML page in a new tab:
<a rel="nofollow" target="_blank" href="your-html-page.html" onclick="window.open(this.href, '_blank'); return false;">Open in new tab</a>
Method 3: Using the window.open
method
You can use the window.open
method to open the HTML page in a new tab:
<a rel="nofollow" target="_blank" href="javascript:window.open('your-html-page.html', '_blank')">Open in new tab</a>
Method 4: Using a button or link with a JavaScript event listener
You can add a button or link to your HTML page and use JavaScript to open the page in a new tab when the button is clicked:
<button onclick="window.open('your-html-page.html', '_blank')">Open in new tab</button>
Method 5: Using a library or framework
If you're using a library or framework like jQuery, you can use its methods to open the HTML page in a new tab:
<a rel="nofollow" target="_blank" href="your-html-page.html" onclick="$('a').attr('target', '_blank');">Open in new tab</a>
Note that the target
attribute and the window.open
method can be used to open the link in a new window or tab, but the target
attribute is more commonly used for this purpose.