我在 SharePoint 内容编辑器 Web 部件 (CEWP) 中使用脚本,该脚本根据名称和时间欢迎用户访问该站点,然后还有另一个链接。我在格式化它时遇到问题。我已经自定义了我的工作脚本,但由于某种原因字体大小和颜色无法正常工作。有人可以指出我正确的方向吗?我认为这与我的“var WelcomeMenuContent”有关,但不确定。
一如既往地感谢任何帮助:
<script type="text/javascript" src="https://wss.companyabc.org/sites/WSS001905/SiteAssets/Libraries/jquery-1.10.2.min.js"></script>
<style type="text/css">
#Header {
font-family: Arial;
color: #cc0717;
font-size: 3em;
text-decoration: underline;
}
#SubHeader {
font-family: Arial;
color:#000000;
font-size: 1.5em;
}
#Hyperlink{
font-family: Arial;
color:#cc0717;
weight: bold;
font-size: 1em;
}
</style>
<center>
<div class="Header">
<span id="greeting">Hello</span>
<script type = "text/javascript">
$(document).ready(function(){
var WelcomeMenuContent = $('.ms-welcomeMenu > a.ms-menu-a > span');
var UserName = WelcomeMenuContent.text();
var FirstName = UserName.split(" ")[0];
var Display;
var Digital = new Date()
var Hours = Digital.getHours()
Morning = 'Good morning' + " " + FirstName;
Lunch = 'Good afternoon' + " " + FirstName;
Evening = 'Good evening' + " " + FirstName;
Night = 'Good night' + " " + FirstName;
TimeElse = 'Welcome' + " " + FirstName;
if (Hours >= 5 && Hours <= 11)
document.getElementById("greeting").innerHTML=(Morning);
else if (Hours >= 12 && Hours <= 17)
document.getElementById("greeting").innerHTML=(Lunch);
else if (Hours >= 18 && Hours <= 22)
document.getElementById("greeting").innerHTML=(Evening);
else if (Hours >= 23 && Hours <= 4)
document.getElementById("greeting").innerHTML=(Night);
else
document.getElementById("greeting").innerHTML=(TimeElse);
});
</script>
</div>
<div class="SubHeader">
<span>Welcome to the home of Company ABC</span>
</div>
</br>
<hr>
</br>
<div class="Hyperlink">
<a href="http://www.google.com">Click here to continue to the Community SharePoint Site</a>
</div>
<hr>
</br>
</center>