我有这个分享点输入:
<input type="button" name="ctl00$ctl40$g_b25debc7_4f96_4b4c_b4bc_f59036684958$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem" value="Guardar" onclick="if (!PreSaveItem()) return false;if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ1')) return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl40$g_b25debc7_4f96_4b4c_b4bc_f59036684958$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem", "", true, "", "", false, true))" id="ctl00_ctl40_g_b25debc7_4f96_4b4c_b4bc_f59036684958_ctl00_toolBarTbl_RightRptControls_ctl00_ctl00_diidIOSaveItem" accesskey="O" class="ms-ButtonHeightWidth" target="_self">
我想点击它时运行功能。但是sharepoint添加了许多属性,我无法添加属性或将其更改为按钮。
单击该按钮后如何运行此功能?
function sendEmail() {
appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
var urlTemplate = appweburl + "/_api/SP.Utilities.Utility.SendEmail";
var fieldUsuario = ctx.CurrentItem.Notificar_x0020_a
$.ajax({
contentType: 'application/json',
url: urlTemplate,
type: "POST",
data: JSON.stringify({
'properties': {
'__metadata': { 'type': 'SP.Utilities.EmailProperties' },
'From': 'bocar@tbocar.onmicrosoft.com',
'To': { 'results': [fieldUsuario] },
'Body': 'Hello',
'Subject': 'remember'
}
}
),
headers: {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data) {
var result = data.d.results;
var i = result.length;
},
error: function (err) {
alert(JSON.stringify(err));
}
});
}
问候!
答案 0 :(得分:1)
在按钮后的某个位置添加<script>
标记:
var button = document.querySelector('input[type="button"][accesskey="O"]');
button.addEventListener('click', function() { sendEmail(); });
这将保留原始处理程序并添加你的。