Link to home
Start Free TrialLog in
Avatar of UTSWPeds
UTSWPedsFlag for United States of America

asked on

Webpart from library - link to document opens in InfoPath and not Browser

InfoPath published to library - library has link to document - works great - opens in browser (default) by clicking on the link (linked to document with edit menu)

However, we created a webpart, using the library, including the same column, linked to document with edit menu and when you click on the link, it opens the file in InfoPath - NOT the browser. We need it to open in browser.

Using the edit menu, I can choose 'Edit in Browser', and it will work, but that's not the behavior we need. We need it to behave just like the link does in the library itself.

Ideas?
Avatar of svetaye
svetaye
Flag of Israel image

Hello,
What did you mean by "we created a web part"? You developed a web part or just added a web part to a page from a Web Parts Gallery?Or maybe it's a Data View?
If it's a regular list web part you can fix it using SharePoint Designer. Just open this page in SharePoint Designer and change the item URL in this Web Part to the Form Server URL.
This URL will look like this:
http://yoursite/_layouts/FormServer.aspx?XmlLocation="+yourItemURL+"&DefaultItemOpen=1

You can find the exactly URL address in the browser address bar when you open a form in the browser mode.

I hope it helps.
Try using a script in a content editor web part that opens any file with the extension ".xml*" in a new or the same browser window.  

We have a CEWP on several pages that has a content link to a file in a "Reusable Script" doc library at the site collection top level.  The (santized) code in that file (/ReusableScript/openPdfNewWindow.htm), is attached.   This one is for opening PDF files in a new window, but you can alter the script to have it open in the same window, I suppose.   The CEWP is invisible on the page (no chrome).

If you un-comment the //alert lines, you can test the script to see what it's doing.  Change the PDF to .xsn, of course, and you may have to warp it further to deal with the nifty mile-long URL extension that Forms server adds, but this script has worked will for us.  I got it a couple of years ago from SharePoint Solutions: http://sharepointsolutions.blogspot.com/2007/09/make-selected-links-in-links-list-open.html.

Good luck.
nsy




<script language="JavaScript"> 
_spBodyOnLoadFunctionNames.push("rewriteLinks");
function rewriteLinks()
{
 
//alert("rewriteLinks function has been called") //to see if the function is even called
 //create an array to store all the anchor elements in the page
     var MyAnchors = document.getElementsByTagName("a");
 
 //loop through the array
     for (var x=0; x<MyAnchors.length; x++)
   {
  	//alert("hyperlink: " + MyAnchors[x].outerHTML);    						//to see what the links are before they're changed
	//alert("index of lower-cased pdf: " + MyAnchors[x].href.toLowerCase().indexOf(".pdf")); 		//to show if it's a pdf	
	var end = MyAnchors[x].target;
	//alert("target: " + end);									//to show target is empty
        
		//if pdf or xls, do something
		if (MyAnchors[x].href.toLowerCase().indexOf(".pdf")>0 || MyAnchors[x].href.toLowerCase().indexOf(".xls")>0)
		{
			//alert("end: " + end);
			
			if (end == "")
				{
					MyAnchors[x].target='"_blank"';
					//alert("new end: " + MyAnchors[x].target);
				}
		}
	}
}
 
</script>

<title></title></head>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of UTSWPeds
UTSWPeds
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of UTSWPeds

ASKER

it worked