发布页面后,内容编辑器Web部件中的Javascript无法正常工作 [英] Javascript in content editor web part not working after publishing the page

查看:62
本文介绍了发布页面后,内容编辑器Web部件中的Javascript无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个发布页面,其中我放置了内容编辑器Web部件,其中包含将用户重定向到应用程序页面的链接。

I have a publishing page in which I have placed content editor web part which contains the link to redirect the user to application page.

内容编辑器Web部件中的代码是:

Code in the content editor web part is:

	<script type="text/javascript">
		function redirectToDownloadsPage() {
		SP.SOD.executeOrDelayUntilScriptLoaded(function(){
			var ctx = SP.ClientContext.get_current();
			var items = SP.ListOperation.Selection.getSelectedItems(ctx);
			var myItems = '';
			var i;
		
			for (i in items) {
				myItems += '|' + items[i].id;
			}
		
			if (myItems) {        
				var siteUrl = url = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl + "/_layouts/15/DownloadImages.aspx?Items=" + myItems;        
				window.location.href = siteUrl
			}
			else {
				alert("Select atleast one item");
			}
		}, "SP.js");
	</script>
	<a onclick="return redirectToDownloadsPage();" href="#"> Download Images </a>

我的问题是当我编辑页面并点击JavaScript工作链接时,我会检查页面,然后JavaScript工作正常,但当我发布页面JavaScript时不起作用。

My problem is when I edit the page and click on the link JavaScript works, then I check in the page then also the JavaScript works fine but when I publish the page the JavaScript does not work.

我缺少什么?

推荐答案

也许你需要修复javascript的javascript错误
Maybe there is an error on the javascript you have to fix the javascript


这篇关于发布页面后,内容编辑器Web部件中的Javascript无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆