none
How to open URL in New Window Through SharePoint custom List RRS feed

  • Question

  • Hi All ,

    I have a SharePoint online Custom LIst that contains many Web name and their urls, now the requirement is i need to create a check box for these urls and when the user checks the checkbox then the urls should open in the new window and the default behaviour is open the url in same window,please help me on this issue.

    Thanks

    Deepak Chauhan


    SharePoint 2010 & 2013 and Office-365 Branding and Front End Customization, UI Design


    • Edited by DeepakChauhan Wednesday, January 21, 2015 5:26 AM
    • Moved by Mr. Wharty Wednesday, January 21, 2015 6:50 AM Not a Training and Certification question
    • Changed type Dennis GuoModerator Thursday, January 22, 2015 8:53 AM question
    Wednesday, January 21, 2015 5:24 AM

Answers

  • Hi Deepak Chauhan,

    The following code for your reference, please add the code into a Content Editor Web Part in the Custom List view page.

    <script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#NewWindow").click(function () {
                $(".ms-listviewtable tr td a").attr("target", "_blank");
            });
        });
    </script>
    
    <input id="NewWindow" type="checkbox" />Open link in new window.

    Best Regards


    Dennis Guo
    TechNet Community Support

    Thursday, January 22, 2015 8:58 AM
    Moderator
  • You can create and display a calculated column with the links, using a formula to determine whether the hyperlink should open in a new window or not.

    Assuming your URL column is actually a single line of text field, rather than a Hyperlink or Picture field, the formula would look like this:

    ="<a"&IF([Checkbox Column]," target='_blank' "," ")&"href='"&[URL Column]&"'>"&[Web Name Column]&"</a>"

    Replace [Checkbox Column], [Url Column], and [Web Name Column] with the appropriate column names (in square brackets if their names contain spaces).

    Note that the calculated column should have a return type of "Number" instead of "Text" or "Yes/No". This ensures that it renders as HTML in a list view web part. Alternatively, you can have a simple workflow copy the value from your calculated column to a rich text field.

    Thursday, January 22, 2015 8:32 PM

All replies

  • Hi Deepak Chauhan,

    The following code for your reference, please add the code into a Content Editor Web Part in the Custom List view page.

    <script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#NewWindow").click(function () {
                $(".ms-listviewtable tr td a").attr("target", "_blank");
            });
        });
    </script>
    
    <input id="NewWindow" type="checkbox" />Open link in new window.

    Best Regards


    Dennis Guo
    TechNet Community Support

    Thursday, January 22, 2015 8:58 AM
    Moderator
  • You can create and display a calculated column with the links, using a formula to determine whether the hyperlink should open in a new window or not.

    Assuming your URL column is actually a single line of text field, rather than a Hyperlink or Picture field, the formula would look like this:

    ="<a"&IF([Checkbox Column]," target='_blank' "," ")&"href='"&[URL Column]&"'>"&[Web Name Column]&"</a>"

    Replace [Checkbox Column], [Url Column], and [Web Name Column] with the appropriate column names (in square brackets if their names contain spaces).

    Note that the calculated column should have a return type of "Number" instead of "Text" or "Yes/No". This ensures that it renders as HTML in a list view web part. Alternatively, you can have a simple workflow copy the value from your calculated column to a rich text field.

    Thursday, January 22, 2015 8:32 PM