Open InfoPath form Hyperlink in Same Window in SharePoint 2013


In this post, we will discuss how we can open InfoPath hyperlink in the same window in SharePoint 2013. Recently in one of my InfoPath form, I was in a need to put one hyperlink in one of the views in the InfoPath form. You can check out this article to know how to add a hyperlink into a SharePoint InfoPath form.

You may also like to read:
Hide ribbon in InfoPath form in SharePoint 2010


InfoPath 2103 string-before and string-after function in SharePoint 2013

Character limits on Multiline Boxes in InfoPath 2013 or 2010

By default when you click on the hyperlink in InfoPath form, the page will open in a new window. But sometimes you may not need that. As in my case, I wanted to open that in the same window.

I did not find any configuration inside the InfoPath form to open in the same page. So I use jQuery to do this. Basically, I remove the target attribute of the hyperlink through jQuery.

Below is the code which you can put in a script editor page. Edit the page where you have put the InfoPath form and then add a script editor web part. This will remove all target attribute from all the links in the page. If you required to remove from a particular hyperlink then you need to modify the code.

<script src=”https://SiteURL/SiteAssets/jquery.min.js”></script>

<script type=”text/javascript”>
function openLinkInSameWindow() {

$(‘a[target=”_blank”]’).removeAttr(‘target’);

}
_spBodyOnLoadFunctionNames.push(“openLinkInSameWindow”);

</script>

Hope this will be helpful to you !!!

Check out Best Alternative to InfoPath -> Try Now

EnjoySharePoint YouTube Channel

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →