I am new to Sharepoint (365) and try to make some Wiki-Webpage. But there is no Contents overview like on Wikipedia or Mediawiki. Since Sharepoint doesn't know PHP I try to create some content-menu in Javascript.
When I add Javascript into the source code of my current webpage, sharepoint removes it with some warning information. The warning wants me to use the webpart option.
Now I have added the js-code in the Webpart, but it looks like the script can't do what I want because it is not included in the site HTML.
When I test the js-code with some alert("test"); I get a reaction. But when I try to get some html content with document.getElementsByTagName('h2'); it does nothing.
Is Javascript the correct way to make some 'content'-overview by lookup the html 'h1' tags? Normaly I would use PHP but Sharepoint doesn't know the language. What is the server-sided language of Sharepoint?
Yes you can use Content Editor Webpart
to add your javascript.
Steps to add Content Editor Webpart
Modify your script like this:-
<script type ="text/javascript">
window.onload=function()
{
var getbyid = document.getElementById("mydiv1");
alert(getbyid.getElementsByTagName("h1")[0].firstChild.data);
};
</script>
<div id="mydiv1">
<h1>Heading 1</h1>
<p>Some text for Heading 1.</p>
<h2>Heading 2</h2>
<p>Some text for Heading 2.</p>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.