javascript 如何从 SP.UI.ModalDialog 获取参数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11970048/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Get args from SP.UI.ModalDialog?
提问by Prisoner ZERO
I have tried other online suggestions without success.
我尝试了其他在线建议但没有成功。
So...
所以...
My function opening a SharePoint dialog passes agrs
into the prescribed option
object, like so:
我打开 SharePoint 对话框的函数传递agrs
给指定的option
对象,如下所示:
SETTING UP THE DIALOG:
Nothing magical here...
设置对话:
这里没有什么神奇的......
function openEmailDialog() {
var options = SP.UI.$create_DialogOptions(),
url = '../Pages/EmailDocument.aspx';
options.title = "Email Documents";
options.width = 1024;
options.height = 400;
options.allowMaximize = false;
options.url = url;
options.args = { DidYouGetThis: true };
SP.UI.ModalDialog.showModalDialog(options);
};
Next...
下一个...
Upon opening the target URL, most online examples recommend the following JavaScript to extract the args
BACK from the dialog, like so:
打开目标 URL 后,大多数在线示例都推荐使用以下 JavaScriptargs
从对话框中提取BACK,如下所示:
GETTING THE ARGS:
Remember, this is JavaScript in a new page which was just opened as a dialog...
获取参数:
请记住,这是一个新页面中的 JavaScript,该页面刚刚作为对话框打开......
$(document).ready(function () {
// This fails because "get_childDialog" doesn't exist
var args = SP.UI.ModalDialog.get_childDialog().get_args();
});
This fails because the SP.UI.ModalDialog
object has no get_childDialog
function.
这将失败,因为该SP.UI.ModalDialog
对象没有get_childDialog
功能。
回答by Jaime Torres
Use var args = window.frameElement.dialogArgs;
利用 var args = window.frameElement.dialogArgs;
The article I used for reference.
直播文章。
回答by brian brinley
Here is a tutorial discussing this very concept. - http://www.sharepointdevelopment.me/2011/06/passing-data-to-and-from-sharepoint-modal-dialogs/
这是一个讨论这个概念的教程。- http://www.sharepointdevelopment.me/2011/06/passing-data-to-and-from-sharepoint-modal-dialogs/