How can I stop hyperlinks appearing in a SharePoint site columns

309 Views Asked by At

Whenever a string which looks like a UNC path appears in a standard SharePoint site column (single or multiple line, plain text) it is interpreted as a hyperlink. The result is that the string

\\server\folder1\folder 2\folder 3\file.txt

appears as

\\server\folder1\folder 2\folder 3\file.txt

If a user clicks on the hyperlinked (bold) location \\server\folder1\folder an attempt is made to open the location, which does not exist. What I would like to do is prevent the interpretation of any part of the site column text as a hyperlink. How can I do this?

1

There are 1 best solutions below

0
buck On

You can use client-side javascript/ jQuery. Either add a content editor webpart or update the page/masterpage in SharePoint designer to include this code. This will work on a view page and on a display page. You could also update the HREF to actually make the link work if you want.

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
<script type="text/javascript">
$(function(){
$("a[href^='file://\\']").each(function(){
        $(this).parent()[0].innerHTML = $(this).parent().text();
    });
});
</script>