Skip to content Skip to sidebar Skip to footer

Open A Tab With A Url When Link Clicked

I want to open a new tab in the same browser when the 'Terms and Conditions' link is clicked which should return the URL: http://localH:30321/OrchardLocal/TermsAndConditions So Far

Solution 1:

First of all sorry for the wrong answer: As you want to open the url in new tab of same browser Which is not possible.It all depends on the browser settings.

http://forums.asp.net/t/1902352.aspx

Open a URL in a new tab (and not a new window) using JavaScript

IF browser setting are default(tested for FF)

this will work Open new tab in same browser window

functionopeninnewTab() {
    var win = window.open("~/TermsAndConditions", '_blank');
    win.focus();
}

Solution 2:

try this

functionnewwin(e) {
    e.preventDefault();
    window.open("/TermsAndConditions", '_blank');
}

by the way you cant use directly "~" in javascript..if you want to use server code like this

functionnewwin(e) {
e.preventDefault();
window.open('<%= ResolveUrl("~/TermsAndConditions") %>', '_blank');
}

EDIT

<p>Accept the <ahref="javascript: void(0)"target="_blank"onclick="newwin()"><spanclass="big-red">Terms and Conditions</span></a></p>

JS

functionnewwin(e) {

    window.open('<%= ResolveUrl("~/TermsAndConditions") %>', '_blank');

    }

or

functionnewwin(e) {

            window.open("/TermsAndConditions", '_blank');

        }

OR pure asp.net code

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

you have to add runat="server" attribute

Solution 3:

<a href='JavaScript:newwin('<%=ResolveClientUrl("~/OrchardLocal/TermsAndConditions")%>');'  >

and

<script>functionnewwin(url) {
        window.open(url,'_blank');
    }
</script>

Solution 4:

One tab is for your href and the other for your onclick. sajad-lfc gave the rigth answer.

Solution 5:

Try the following piece of code

<p>Accept the <ahref="~/"target="_blank"onclick="newwin()"><spanclass="big-red">Terms and Conditions</span></a></p><script>
    $("span.big-red").on("click", function () {
        window.open('www.yourdomain.com', '_blank');
    });
</script>

This is working perfectly hopefully works for you.

Post a Comment for "Open A Tab With A Url When Link Clicked"