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 ?
Asked
Active
Viewed 248 times
1
-
exactly not getting what you want.can you share more details? – SynozeN Technologies May 09 '17 at 07: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 May 09 '17 at 07:27
1 Answers
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
Danny '365CSI' Engelman
- 21,176
- 7
- 35
- 79
-
thanks danny , how do i replace the keyword "Author" in the body with page from text passed as QueryString ? – Rinu May 09 '17 at 08: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.querySelectorJS 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.querySelectoris standard vanilla JS code since IE9, so all jQuery answers are telling you to code the way we did in the (far) IE past – Danny '365CSI' Engelman May 09 '17 at 08: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 – Danny '365CSI' Engelman May 09 '17 at 08: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 – Rinu May 09 '17 at 11:04
-
i just put a dummy class 'aap'
Author to identify the tag and replace the inner html – Rinu May 09 '17 at 11:08 -
-
naa it's just random letters i picked up :). but the above are not working . i have added the function in a script editor as advised. am i doing something wrong ? – Rinu May 09 '17 at 11:31
-
Does this function run on page load or do we have to have some mechanism to call in on page load ? – Rinu May 09 '17 at 11:55
-
okay, take one step back and learn to execute JavaScript after pageload – Danny '365CSI' Engelman May 09 '17 at 12:13
-
-