1

we have several pages with same contents the only difference is the author. instead of creating multiple pages for each author in sharepoint can we not change the author and may be very few select keys based on the hyperlink clicked to get to the page ?

2
  • exactly not getting what you want.can you share more details? Commented May 9, 2017 at 7:20
  • Simply put. I want to be able to change the content/text of a page based on hyperlink on the other. say if the text of the hyperlink is "mark" that text will be replace author keyword on the page linked to the hyperlink.
    – Rinu
    Commented May 9, 2017 at 7:27

1 Answer 1

2

You can pass variables in the QueryString (everything after the ? in the URL)

Then use JavaScript to read those Parameters (What does this code getQueryStringParameter do?) and display content

11
  • thanks danny , how do i replace the keyword "Author" in the body with page from text passed as QueryString ?
    – Rinu
    Commented May 9, 2017 at 8:21
  • You have to learn JavaScript (and Conten/Scrip Editor WebParts) to do that, the link gets you the JS code to read the QueryString, then you use the document.querySelector JS function to targer a location in the HTML page, and replace its innerHTML. Note most will tell you to use jQuery, but that requires you to load a 90 KB jQuery library (extending your learning track) document.querySelector is standard vanilla JS code since IE9, so all jQuery answers are telling you to code the way we did in the (far) IE past Commented May 9, 2017 at 8:32
  • Tip: Learn to use F12 Snippets in the Chrome Browser, it allows you to code against SharePoint without reloading the page every time; saves you heaps of trial/error reloads. When your snippet works, you paste it into a Content/Script Editor WebPart...... Remember; You are getting into SharePoint programming now... learning new things takes BS&T Commented May 9, 2017 at 8:37
  • it looks pretty straightforward and easy however i am having trouble getting the output. i sent the text over by appending url?Author=mathew and was able to see it in the url of the next page. in the script editor i used <script type="text/javascript"> function myFunction() { var value=getQueryStringParameter('Author'); document.querySelector(".aap").innerHTML = var; } </script>
    – Rinu
    Commented May 9, 2017 at 11:04
  • i just put a dummy class 'aap' <td class="ms-rteTable-default aap">Author</td> to identify the tag and replace the inner html
    – Rinu
    Commented May 9, 2017 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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