Office.Urls interface
提供加载项使用的运行时环境的 URL。
属性
| javascript |
获取加载项的 JavaScript 运行时的 URL。 |
属性详细信息
javascriptRuntimeUrl
获取加载项的 JavaScript 运行时的 URL。
javascriptRuntimeUrl: string;
属性值
string
注解
最低权限级别: 受限
适用的 Outlook 模式:Compose 或 Read
重要说明:
返回的 URL 指向 JavaScript 文件的位置,经典 Outlook on Windows 用于处理基于事件的激活和集成垃圾邮件报告。 若要了解有关这些功能的详细信息,请参阅 使用事件激活加载项 和 实现集成垃圾邮件报告加载项。
在 Outlook 网页版、Mac 和 Windows 上的新 Outlook 中,实现任务窗格的加载项不支持此 API。 在这些客户端上,只有实现基于事件的激活或集成垃圾邮件报告的加载项才支持 API。
如果加载项使用仅加载项清单,则返回的 URL 将匹配
resid类型为 RuntimeOverride 元素javascript的值。 若要了解详细信息,请参阅 运行时的替代元素。如果加载项使用 Microsoft 365 统一清单,则返回的 URL 将与“extensions.runtimes.code”对象中的属性值
script匹配。
示例
// Get the value of the first parameter of the JavaScript runtime URL.
// For example, if the URL is https://wwww.contoso.com/training?key1=value1&key2=value2,
// the following function logs "First parameter value: value1" to the console.
const url = Office.context.urls.javascriptRuntimeUrl;
const regex = /=([^&]+)/;
console.log(`First parameter value: ${url.match(regex)[1]}`);