您好我正在尝试通过在页面中插入三个日历Web部件以及在CEWP中插入以下代码来开发三个月滚动日历视图。
日历应分别滚动到上一个或下一个,但点击“PrevMonth”和“NextMonth”按钮。
这似乎只适用于滚动,但有些事情是错误的。有人可以帮我这个吗?
< script type = "text/javascript" >
$(document).ready(function() {
window.setTimeout(setCal, 1000);
});
var CurrentDate = new Date();
function setCal() {
$("#PrevMonth").click(PrevMonth);
$("#NextMonth").click(NextMonth);
MoveToDate((CurrentDate.getMonth() + 2).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ3');
MoveToDate((CurrentDate.getMonth() + 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ2');
MoveToDate((CurrentDate.getMonth()).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ1');
}
function PrevMonth() {
MoveToDate((CurrentDate.getMonth() - 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ3');
MoveToDate((CurrentDate.getMonth() - 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ2');
MoveToDate((CurrentDate.getMonth() - 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ1');
}
function NextMonth() {
MoveToDate((currentMonth + 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ3');
MoveToDate((currentMonth + 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ2');
MoveToDate((currentMonth + 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ1');
}
<
/script>
答案 0 :(得分:0)
经过大量搜索后,您可以完美地运作。
<script type="text/javascript" src="http://sharepoint server/sites/page/Scripts/jquery.SPServices.js"></script>
<script src="https://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
function myPrevFunction() {
document.getElementById("WPQ3_nav_prev_img").click();
document.getElementById("WPQ4_nav_prev_img").click();
document.getElementById("WPQ5_nav_prev_img").click();
document.getElementById("WPQ6_nav_prev_img").click();
document.getElementById("WPQ7_nav_prev_img").click();
document.getElementById("WPQ8_nav_prev_img").click();
}
function myNextFunction() {
document.getElementById("WPQ3_nav_next_img").click();
document.getElementById("WPQ4_nav_next_img").click();
document.getElementById("WPQ5_nav_next_img").click();
document.getElementById("WPQ6_nav_next_img").click();
document.getElementById("WPQ7_nav_next_img").click();
document.getElementById("WPQ8_nav_next_img").click();
}
</script>
<input type="button" id="CFCCalPrev" value="Prev" onclick="myPrevFunction()">
<input type="button" id="CFCCalNext" value="Next" onclick="myNextFunction()">