Hi all i am very new to SharePoint i am working on SharePoint online. have admin rights. I am not using any SharePoint server or designer. I mapped my network drive to SharePoint and copy pasted a simple aspx page which has different layout to the site pages folder. This page is not in site definition and is a custom page. I want to display current user id on the page i searched a lot on net i was able to get the code but you are not allowed to use code behind file neither can you write code on the page so i thought of using script to get it. I ran a simple script and it runs on the page so i tried to get user id through it but it is not working.
<script>
(function myfunction() {
var propertyValue = Microsoft.SharePoint.SPContext.Current.Web.CurrentUser.LoginName;
document.write(propertyValue);
})()
</script>
I also tried this
<script type="text/javascript">
var loginName = _spPageContextInfo.userLoginName;
document.write(loginName);
</script>
May be my my page is not part of SharePoint structure
Do i need to add any references on my page or is there some other way i can get the current logged in user id