2

I am trying to add a 'back a page' link in SharePoint using

<a href="javascript:history.back();">[Go Back]</a>

But as soon as I save the page, it removes the javascript link. Is there another way I should be doing it?

Thanks

2
  • It works with input type, see SteffPoints answer
    – Alberti75
    Jun 22, 2016 at 12:23
  • Do you know how to use input type as an image instead? See my comment below on SteffPoint. Jun 22, 2016 at 14:18

3 Answers 3

3

Fortunately I lately also needed a back button, so I can give you a working solution for it: Just simply add this Code to a Script Editor Web Part or Content Editor Web Part on the Site where u want it.

<input type="button" value="back" onclick="window.history.back()"
 style="color: white; background-color:rgb(196, 196, 196); 
font: 15px arial, sans-serif; font-weight: bold;" /> 
3
  • Thanks for you help, Ive tried modifying use a image instead, but it wont go back a page now. Please can you check my code? 'code' <input type="image" src="/testsite/knowledegbase/TestMG2/PublishingImages/addaproduct.png" onclick="window.history.back()"/> 'code' Jun 22, 2016 at 14:05
  • 1
    I would rather define your image as background of the button. Add the following CSS within the tag: style="background: url(myimage.png)"
    – SteffPoint
    Jun 22, 2016 at 14:25
  • Thankyou, all working now! Jun 22, 2016 at 15:46
0

Follow below mentioned steps :

  • Write your code in a text file.
  • upload it to any library.
  • Now open your webpart page in edit mode
  • Add Content Editor wbpart
  • go to webpart setting.
  • set path for the txt file uploaded in library
  • click ok and you are all set
0

try this

<button class="btn btn-default" type="button" onclick="history.go(-1);" id="btBack">Back</button>

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.