Powered by Blogger.

Thursday, February 27, 2014

How to open hyperlink in new tab using jQuery or JavaScript?



In this post we will discuss how to open hyperlinks in new tab using jQuery. Also you can check my previous post on:

- How to use If else in sql server 2008?

- Bind dropdownlist using arraylist or hashtable in C#.Net

- Convert first letter to uppercase in C#.Net

Follow below steps to open hyperlink in new tab using jquery:

1st Step:
Add .js file to page as like below:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>

2nd Step:
Write the script like below:

<script type="text/javascript">
       $('.divclassname a').live('mouseover', function () {
           $(this).attr('target', '_blank');
       });
    </script>

Follow below steps to open hyperlink in new tab using JavaScript:

<script type="text/javascript">
        $(function () {
            $("a").attr("target", "_blank");
        });
    </script>

Rememeber we have to write the above code inside <head> </head> tag in our .aspx page





0 comments

Post a Comment