我有一个Microsoft的 SharePoint 2010 安装,当我使用集成搜索搜索项目时,我看到结果具有以下 javascript 调用:
<a id="SRB_g_b60c4a68_5348_49ec_846c_b9d069d6774d_1_Title" href="javascript:openDialogSearch('https://example.com/xyz/DispForm.aspx?ID=1');" title="This is just a test"><strong>Test</strong></a>
现在我需要从同一个内部网的外部站点调用相同的调用js函数(openDialogSearch(。
我已经看到这个函数是在页面脚本中定义的,该脚本调用以下传递资源 url 的函数:
SP.UI.ModalDialog.showModalDialog(url)
如何从不在 SharePoint 内部的外部 HTML 页面调用相同的函数?
我不建议尝试从SP重新创建对话框基础结构:
相反,请使用类似于jQuery对话框的对话框: https://jqueryui.com/dialog/
您需要更改此代码才能访问您的 SP URL。
您还将进行配置更改。 您需要允许从您的 URL 访问 SP,否则,您将收到访问控制允许源错误。 这是对给定网站集的 SP web.config 文件的更新。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://jqueryui.com/dialog/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$("#dialog").load("PUT YOUR URL HERE").dialog({modal:true});
//$("#dialog").dialog();
} );
</script>
</head>
<body>
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
</body>
</html>