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 ?
-
exactly not getting what you want.can you share more details?– SynozeN TechnologiesMay 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.– RinuMay 9, 2017 at 7:27
1 Answer
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
-
thanks danny , how do i replace the keyword "Author" in the body with page from text passed as QueryString ?– RinuMay 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 itsinnerHTML
. 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 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 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>– RinuMay 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– RinuMay 9, 2017 at 11:08