1

I have an InfoPath Form Web Part on a SharePoint 2010 page. The form has a bunch of hyperlinks which by default InfoPath opens in a new window, but I added the code below in a CEWP on the SharePoint page so that all links open in the same window (target = "_self"). My question is, how do I modify the code so that I can choose which links open in the same window, for example I want some links to continue opening in a new window because they are external URLs, while I want URLs to other pages on the SharePoint site to open in the same window, so I need more dynamic code that lets me set only the hyperlinks I choose to open in the same window, and then the default InfoPath functionality should take care of all the other links for them to continue opening in a new window. Thanks in advance for your help!

Code:

_spBodyOnLoadFunctionNames.push("rewriteLinks"); function rewriteLinks() { var links = document.getElementsByTagName('a'); var len = links.length; for(var i=0; i[less than symbol]len; i++) { links[i].target = "_self"; } }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.