如何通过javascript单击Dynamics 365功能区按钮
我正在尝试找出如何单击D365功能区上的按钮。该按钮将刷新页面,我将执行此路线,因为最终我希望刷新页面上的所有元素。 我曾尝试通过查询选择器访问,但没有成功如何通过javascript单击Dynamics 365功能区按钮,javascript,jquery,dynamics-crm,Javascript,Jquery,Dynamics Crm,我正在尝试找出如何单击D365功能区上的按钮。该按钮将刷新页面,我将执行此路线,因为最终我希望刷新页面上的所有元素。 我曾尝试通过查询选择器访问,但没有成功 document.querySelector("#rr_jobprofile\\|NoRelationship\\|Form\\|Mscrm\\.Modern\\.refreshCommand72 > button").click(); 按钮的html <button aria-label="R
document.querySelector("#rr_jobprofile\\|NoRelationship\\|Form\\|Mscrm\\.Modern\\.refreshCommand72 > button").click();
按钮的html
<button aria-label="Refresh" aria-hidden="true" title="Refresh" tabindex="-1" data-id="rr_jobprofile|NoRelationship|Form|Mscrm.Form.rr_jobprofile.RefreshModernButton" data-lp-id="Form:rr_jobprofile-rr_jobprofile|NoRelationship|Form|Mscrm.Form.rr_jobprofile.RefreshModernButton" type="button" class="pa-ak pa-kx pa-go pa-ep pa-aj pa-om pa-at pa-sx pa-sy flexbox"><span class="pa-az pa-ah pa-a pa-hh "><span class="pa-ho pa-hj pa-st pa-cd pa-bd pa-a pa-at "><img src="/uclient/resources/images/Refresh.svg?v=1.4.2043-2012.2" alt="" title="" class="pa-oh pa-cg pa-bd pa-cc "></span><span aria-label="Refresh" tabindex="-1" class="pa-hj pa-bd pa-st pa-v pa-e pa-cm pa-oz pa-cl ">Refresh</span></span></button>
刷新
试试看
数据属性的选择器使用语法,而不是以标记名或字符开始。比如说
选择一个按钮,该按钮的按钮[data id=xxxx]
属性值正好是数据id
xxxx
选择其按钮[data id |=xxxx]
xxxx`开头的按钮 `数据id属性值以
function refreshWebResource(executionContext, WebRrscName) {
var _crmForm = executionContext.getFormContext();
var webResource = _crmForm.getControl(WebRrscName);
if (webResource != null) {
var webResourceSrc = webResource.getSrc();
webResource.setSrc(null);
webResource.setSrc(webResourceSrc);
}
}
无法读取null的属性“click”。请确保在加载页面后运行该属性
window.onload=function(){document.querySelector('xxxyyzzz')。单击()}
。如果仍然是null
,则需要找到查询选择器的静态属性以标识元素。刷新页面几次,然后找到数据id
的公共部分,该部分在刷新页面后不应更改。不要在DOM for CRM中导航。您正在引用的属性选择器可以随时更改,而不会发出警告。不支持访问DOM有一个很好的理由。crm已经提供了刷新按钮,用户可以手动单击该按钮。如果您想使用javascript(微软提供的方法)刷新页面,则不必使用dom对象。看看这段,谷歌搜索了代码,找到了原始的源代码,贴在这里,给它应得的信用。
function refreshWebResource(executionContext, WebRrscName) {
var _crmForm = executionContext.getFormContext();
var webResource = _crmForm.getControl(WebRrscName);
if (webResource != null) {
var webResourceSrc = webResource.getSrc();
webResource.setSrc(null);
webResource.setSrc(webResourceSrc);
}
}