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
function openinnewTab() {
var win = window.open("~/TermsAndConditions", '_blank');
win.focus();
}
Solution 2:
try this
function newwin(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
function newwin(e) {
e.preventDefault();
window.open('<%= ResolveUrl("~/TermsAndConditions") %>', '_blank');
}
EDIT
<p>Accept the <a href="javascript: void(0)" target="_blank" onclick="newwin()"> <span class="big-red">Terms and Conditions</span></a></p>
JS
function newwin(e) {
window.open('<%= ResolveUrl("~/TermsAndConditions") %>', '_blank');
}
or
function newwin(e) {
window.open("/TermsAndConditions", '_blank');
}
OR pure asp.net code
<p>Accept the <a runat="server" href="~/TermsAndConditions" target="_blank" > <span class="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>
function newwin(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 <a href="~/" target="_blank" onclick="newwin()"> <span class="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"