Office API是否支持将参数传递给Office加载项?通过单击文档URL在Office 365中打开Word文档时
我们可以在外接程序环境中访问的URL中传递一些查询字符串吗?
答案 0 :(得分:0)
是的,可以。您可以参考以下代码:
function getParameterByName(name, url) {
// This URL is written directly, you could replace it with your variable.
if (!url) url = "https://username-my.sharepoint.com/:w:/r/personal/username_tenantname_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc=%7QAF15650B-72D2-447C-BE9C-9201A7F61BA4%7D&file=Document%20158.docx&action=default&mobileredirect=true";
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
致电:
var sourcedoc = getParameterByName('sourcedoc');
var file = getParameterByName('file');
var action = getParameterByName('action');
var mobileredirect = getParameterByName('mobileredirect');
您可以参考以下链接: