我在SharePoint Online帳戶中設置了腳本編輯器Web部件。結果顯示當我編輯頁面,但不是當瀏覽頁面。這個jQuery,Moment.js腳本不會在SharePoint Online腳本編輯器Web部件中顯示,有什麼想法爲什麼?
下面是我使用的腳本:
<h3>You got married: <span id="married"></span></h3>
<h3>Adam was born: <span id="adamBorn"></span></h3>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://mysite.sharepoint.com/tech/Scripts/moment-with-langs.js"> </script>
<script>
function setMoments(){
var married = $('#married'),
date = moment("1951-12-05", "YYYY-MM-DD"),
update = function(){
married.html(date.fromNow());
};
update();
var adamBorn = $('#adamBorn'),
date = moment("1992-06-14", "YYYY-MM-DD"),
update = function(){
adamBorn.html(date.fromNow());
};
update();
};
_spBodyOnLoadFunctionNames.push("setMoments");
</script>
我也嘗試過使用的document.ready,但是結果還是瀏覽網頁時不顯示。
嘗試把_spBodyOnLoadFunctionNames.push( 「setMoments」) ;在腳本標籤的頂部。 –
@ Yevgeniy.Chernobrivets沒有運氣。相同的結果。 – Mark