Paul Taylor
Paul Taylor

Reputation: 13110

Can I force click on hyperlink to open in new tab when click on link

Can I force click on hyperlink to open in new page when click on link?

My page is part of a frameset, and links to one site has changed so it prevents the link working if comes form a frameset, but its fine if user does does cntl-click to open page in new tab.

But user doesn't know that so I want a usual click to open in new tab as well to workaround this issue.

Upvotes: 1

Views: 4834

Answers (3)

Jeffrey Roosendaal
Jeffrey Roosendaal

Reputation: 7157

With just HTML:

<a href="www.targetpage.com" target="_blank"> Click here </a>

Documentation on target


You can also try with javascript (jQuery):

$('a.myLink').trigger(
    $.Event('click', {
        ctrlKey: true
    })
);

Documentation on Event

Upvotes: 4

user6426675
user6426675

Reputation:

Use target="_blank" inside your link tag:

<a href="link" title="link title" target="_blank">link title</a>

See: https://www.w3schools.com/tags/att_a_target.asp

Upvotes: 2

Gokulakrishnan M
Gokulakrishnan M

Reputation: 360

<p> <a href="https://www.w3schools.com" target="_blank">click here</a></p>

use target="_blank" it will open the link in new tab

Upvotes: 2

Related Questions