简体   繁体   English

如何使用Office Js在Excel加载项中显示提示框?

[英]How to show prompt alert box in Excel add-ins using Office Js?

I'm new to office js.我是办公室 js 的新手。 Just I need to show prompt alert box using office Js but Javascript alert not working inside office js.只是我需要使用 office Js 显示提示框,但 Javascript 警报在 office js 中不起作用。 Can someone help me to do this?有人可以帮我做这个吗?

Expected alert box预期的警告框

You can use the Office dialog API to open dialog boxes in your Office Add-in.您可以使用Office 对话框 API在 Office 加载项中打开对话框。

To open a dialog box, your code, typically a page in a task pane, calls the displayDialogAsync method and passes to it the URL of the resource that you want to open.要打开对话框,您的代码(通常是任务窗格中的页面)调用 displayDialogAsync 方法并将要打开的资源的 URL 传递给它。 The page on which this method is called is known as the "host page".调用此方法的页面称为“主机页面”。 For example, if you call this method in script on index.html in a task pane, then index.html is the host page of the dialog box that the method opens.例如,如果您在任务窗格中的 index.html 上的脚本中调用此方法,则 index.html 是该方法打开的对话框的宿主页面。

The resource that is opened in the dialog box is usually a page, but it can be a controller method in an MVC application, a route, a web service method, or any other resource.在对话框中打开的资源通常是页面,但它可以是 MVC 应用程序中的 controller 方法、路由、web 服务方法或任何其他资源。 The page or website refers to the resource in the dialog box. pagewebsite是指对话框中的资源。 The following code is a simple example:下面的代码是一个简单的例子:

Office.context.ui.displayDialogAsync('https://yourAddinDomain/yourDialog.html');

Read more about that in the Use the Office dialog API in Office Add-ins article. 在 Office 加载项中使用 Office 对话框 API 一文中阅读更多相关信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM