1

I want to add an anchor link in a document library to redirect to another page. How can I do this? The anchor link is:

<a onclick="javascript:location.href='UploadDocuments.aspx' + location.search">Save</a>

3
  • 1
    You want it in Dispform or in Allitems?
    – XristosK
    Apr 5, 2016 at 9:42
  • I want to add this anchor link in Allitems.aspx Page. how can I do this please help me. thanks Apr 5, 2016 at 16:04
  • When I am using this link in calculate column syntax error has occurs . what syntax need to add this- <a onclick="javascript:location.href='UploadDocuments.aspx' + location.search">Save</a> link Apr 5, 2016 at 16:05

3 Answers 3

0

When used in a Calculated Column Formula (set tot datatype=Number/DateTime so it outputs as HTML in A View (and View only)) you have to escape the "(double quote) properly:

="<a onclick=""javascript:location.href='UploadDocuments.aspx' + location.search"">Save</a>"
4
  • Link is working fine and redirect to another page using above formula but SPHostUrl is not passed to redirect page using "location.search". What may be reason for that ? Apr 8, 2016 at 11:56
  • I copied your code; Does it require a ? to specify location.search as parameter maybe... Apr 8, 2016 at 18:02
  • I have try ? in to specify location.search as parameter but it redirect to target page but SPHost Url is not passes still. please give me another solution for this. Apr 12, 2016 at 16:08
  • Forget all the SharePoint stuff; first get your URL right Apr 12, 2016 at 18:51
0

Consider using Client Side Rendering and JSLinks. Sample code can be found here

0

You can use approach of using calculated column and achieve your functionality..

Look into this blog, this will provide you all you need to create hyperlink using Caluclated Column on List View.

https://devdotnotes.wordpress.com/2012/01/29/sharepoint-caculated-column-and-hyperlink-no-workflow-or-script-needed/

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.