John
John

Reputation: 3945

Open a new tab with the link clicked

So using the below link, when the user clicks on 'Terms and Conditions' I would like the T&C page to open in a separate browser. ATM it reloads the browser with the T&C page. I thought '_blank' opened a new tab?

<p>
     Accept the <a href="~/TermsAndConditions" target=\"_blank\">
     <span class="big-red">Terms and Conditions</span>
     </a>
</p>

Upvotes: 1

Views: 2765

Answers (1)

Afzaal Ahmad Zeeshan
Afzaal Ahmad Zeeshan

Reputation: 15860

You cannot open a new tab in seperate browser

Opening a new tab in a seperate browser isn't possible, I will assume you meant a new window of the same browser.

You don't need to \" escape qoutes

And please note that you need to escape qoutes once you are inside the qoutes such as:

"<a href=\"href\"></a>"

Since you're in plain HTML and not inside some qoutations, so you don't need to write these statements. They are needed to tell the code that these qoutation signs are to written inside plain HTML and should not be treated as endings of the block qoutes!

Use JS

However you can do this:

<a href="~/" target="_blank">Terms And Conditions</a>

You need to write this JS code

onclick="newwin()" // in the a tag

In the JS file as this:

function newwin () {
   window.open("link"); // ~/termsandconditions
}

PS, target="_blank" does open a new tab

However, target="_blank" opens a new tab! :) So it is OK.

Upvotes: 1

Related Questions