让按钮打开一个新窗口

时间:2017-07-29 11:34:31

标签: ms-office office-js

我想在我的加载项的选项卡下添加一个按钮,然后单击该按钮应该在新窗口或对话框中打开一个URL。我尝试了以下内容:

<Group id="Contoso.Tab1.Group2">
    <Label resid="Contoso.Tab1.GroupLabel" />
    <Icon>
        <bt:Image size="16" resid="Contoso.TaskpaneButton3.Icon" />
        <bt:Image size="32" resid="Contoso.TaskpaneButton3.Icon" />
        <bt:Image size="80" resid="Contoso.TaskpaneButton3.Icon" />
    </Icon>
    <Control xsi:type="Button" id="Contoso.TaskpaneButton3">
        <Label resid="Contoso.TaskpaneButton3.Label" />
        <Supertip>
            <Title resid="Contoso.TaskpaneButton3.Label" />
            <Description resid="Contoso.TaskpaneButton3.Tooltip" />
        </Supertip>
        <Icon>
            <bt:Image size="16" resid="Contoso.TaskpaneButton3.Icon" />
            <bt:Image size="32" resid="Contoso.TaskpaneButton3.Icon" />
            <bt:Image size="80" resid="Contoso.TaskpaneButton3.Icon" />
        </Icon>
        <Action xsi:type="ShowTaskpane">
            <TaskpaneId>Button3</TaskpaneId>
            <SourceLocation resid="Contoso.Taskpane3.Url" />
        </Action>
    </Control>
</Group>

... ...

   <bt:Url id="Contoso.Taskpane3.Url" DefaultValue="https://www.stackoverflow.com/" />

问题是它仍然试图在任务窗格中打开该链接,而不是在新窗口或对话框中打开。有谁知道如何修改清单来实现这个目标?

1 个答案:

答案 0 :(得分:0)

在google关于office dev之后,我发现你可以将动作标签更改为

<!-- This is what happens when the command is triggered (E.g. click on the Button). Supported actions are ExecuteFunction or ShowTaskpane. -->
              <Action xsi:type="ExecuteFunction">
                <FunctionName>doSomethingAndShowDialog</FunctionName>
              </Action>

检查以下链接可能会有所帮助

https://github.com/OfficeDev/Office-Add-in-Dialog-API-Simple-Example