0

我正在编辑一个共享点母版页,其中包含在我的头标记的最顶部、对 labJS 的调用和一个 scriptloader.js 文件。

这是该文件包含的内容:

$LAB
    .script("/Style Library/libs/jquery-1.10.2.min.js")
    .script("/Style Library/libs/jquery-ui.min.js")
    .script("https://www.google.com/jsapi")
    .script("/Style Library/libs/jquery.SPServices-2013.01.min.js")
    .script("/Style Library/libs/angular.min.js")
    .script("/Style Library/libs/knockout-3.0.0.js")
    .script("/Style Library/addons/wpToggle/wpToggle-jQuery.js")
    .script("/Style Library/addons/spCharts/spjs-charts-v4.js")
    .script("/Style Library/addons/quickLaunchToggle/jQuery.LISP.quicklaunch.js")

在我的共享点站点上,我有一个较小的 html 页面,其中包含一个时钟

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CSS3 Digital Clock with jQuery</title>
<style type="text/css"></style>
<script type="text/javascript">
$(document).ready(function() {
// Create two variable with the names of the months and days in an array
var monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; 
var dayNames= ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]

// Create a newDate() object
var newDate = new Date();
// Extract the current date from Date object
newDate.setDate(newDate.getDate());
// Output the day, date, month and year    
$('#Date').html(dayNames[newDate.getDay()] + ", " +monthNames[newDate.getMonth()]+ ' ' +  newDate.getDate()  + ', ' + newDate.getFullYear());

setInterval( function() {
    // Create a newDate() object and extract the seconds of the current time on the visitor's
    var seconds = new Date().getSeconds();
    // Add a leading zero to seconds value
    $("#sec").html(( seconds < 10 ? "0" : "" ) + seconds);
    },1000);

setInterval( function() {
    // Create a newDate() object and extract the minutes of the current time on the visitor's
    var minutes = new Date().getMinutes();
    // Add a leading zero to the minutes value
    $("#min").html(( minutes < 10 ? "0" : "" ) + minutes);
    },1000);

setInterval( function() {
    // Create a newDate() object and extract the hours of the current time on the visitor's
    var hours = new Date().getHours();
    // Add a leading zero to the hours value
    $("#hours").html(( hours < 10 ? "0" : "" ) + hours);
    }, 1000);

}); 
</script>
</head>
<body>
<div class="clockContainer">
<div class="clock">
    <div id="Date"></div>
        <ul>
            <li id="hours"> </li>
            <li id="point">:</li>
            <li id="min"> </li>
            <li id="point">:</li>
            <li id="sec"> </li>
        </ul>
    </div>
</div>
</body>
</html>

我的控制台在我的页面的第 1472 行给了我这个错误,但是 scriptloader.js 文件基本上在开始标记之后被调用。

4

2 回答 2

1

当我在 SP 上遇到 JQuery 问题时,我使用以下代码段:

var j = jQuery.noConflict();
ExecuteOrDelayUntilScriptLoaded(run, "sp.js");

function run(){
   j('#selector').method();
}
于 2013-12-10T07:37:09.353 回答
1

尝试使用_spBodyOnLoadFunctionNames数组而不是document.ready。

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("myCustomFunctionName");
function myCustomFunctionName() {
...
} 
</script>
于 2013-12-10T07:07:20.587 回答