本文介绍了使用JavaScript根据月份更改SharePoint 2013图片库中的默认显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

因此,我试图显示图片库中的一幅图像作为默认图像,具体取决于月份.我已经创建了图片库,并且正在幻灯片"视图中使用它;我要显示的图像是本月的日历之一.我想要 例如,用户每月要查看适当的图片:3月中,3月日历图片应该是用户首先查看的图片,但是他/她仍然可以切换幻灯片.

So I am trying to display one image from a picture library as the default image depending on month. I have created the picture library and I am using it in Slides view; the image that I want displayed is one with the calendar of the present month. I want the user to see the appropriate picture each month, for example: in March the March calendar picture should be the first to be viewed by the user, however he/she can still switch slides.

到目前为止,我在脚本编辑器中插入了一些代码(该代码不起作用),如下所示:

So far, I have some code that I inserted in a script editor (which is not working), as follows:

<html>
<body>
<script type="text/javascript">
	var now = new Date();
	var month = now.getMonth();

	if (month == 1)
		{
			{document.write('<img src="January 2018.png">');
                }
	else if (month == 2)
		{
			{document.write('<img src="February 2018.png">');
                }
        else if (month == 3)
		{
			{document.write('<img src="March 2018.png">');
                }	
        else if (month == 4)
		{
			{document.write('<img src="April 2018.png">');
                }
        else if (month == 5)
		{
			{document.write('<img src="May 2018.png">');
                }
        else if (month == 6)
		{
			{document.write('<img src="June 2018.png">');
                }
        else if (month == 7)
		{
			{document.write('<img src="July 2018.png">');
                }
        else if (month == 8)
		{
			{document.write('<img src="August 2018.png">');
                }
        else if (month == 9)
		{
			{document.write('<img src="September 2018.png">');
                }
        else if (month == 10)
		{
			{document.write('<img src="October 2018.png">');
                }
        else if (month == 11)
		{
			{document.write('<img src="November 2018.png">');
                }
        else
		{
        document.write('<img src="December 2017.png">');
                }
</script>
</body>
</html>

有人可以帮我继续吗?

推荐答案

我们可以在页面加载中使用Jquery覆盖幻灯片Web部件的默认imgae标签,如下所示:

We can override the slide web part default imgae tag with Jquery in Page load like below:

<script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
var now=new Date();
var month=now.getMonth()+1;




这篇关于使用JavaScript根据月份更改SharePoint 2013图片库中的默认显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 03:55