我创建了一个SP Hosted应用程序..然后我添加了一个Ribbon Custom Action并选择了“Host Web”
我添加了以下XML:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="cautionIcon"
Location="CommandUI.Ribbon">
<CommandUIExtension>
<!--
Update the UI definitions below with the controls and the command actions
that you want to enable for the custom action.
-->
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.EditingTools.CPInsert.Groups._children">
<Group
Id="UploadLinkRibbonActionGroup"
Sequence="80"
Description="This group will contain the Button control"
Title="Caution"
Template="Ribbon.Templates.Flexible2">
<Controls Id="UploadLinkControl">
<Button
Id="CautionButton"
Command="UploadLinkButtonCommand"
Image32by32="/sites/insightdeveloper/PublishingImages/mrT32.png"
LabelText="Caution"
TemplateAlias="o1"
Sequence="10"/>
</Controls>
</Group>
</CommandUIDefinition>
<CommandUIDefinition
Location="Ribbon.EditingTools.CPInsert.Scaling._children">
<MaxSize
Id="CustomEditRibbonActionsOneMaxSize"
Sequence="15"
GroupId="UploadLinkRibbonActionGroup"
Size="LargeLarge"/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="UploadLinkButtonCommand"
CommandAction="~appWebUrl/Pages/Default.aspx?{StandardTokens}"/>
</CommandUIHandlers>
</CommandUIExtension >
这会在我的功能区上添加一个按钮。
问题是我在CommandAction中更改~appWebUrl后无法调用任何自定义JS我尝试部署时出错。 “验证应用程序包时出错”。
我希望能够在命令操作“javascript:alert('hello');”上添加一些JS。但是只要~appWebUrl丢失,我就会收到错误。我对SP 2010没有这个问题,这很容易。
感谢任何帮助!
答案 0 :(得分:2)
在SharePoint 2013中,自定义操作网址必须以&#34; http:&#34;,&#34; https:&#34;,&#34; ~appWebUrl&#34;或&#34; ~remoteAppUrl&#34;。 SharePoint 2010它工作正常。检查以下内容:
&#34; CustomAction不能包含JavaScript:任何UrlActions或CommandActions都必须是要导航到的URL。除了特定于应用的令牌之外,还可以使用常规自定义操作令牌对URL进行参数化。&#34;从这里: https://msdn.microsoft.com/en-us/library/jj220046.aspx?f=255&MSPPError=-2147217396