I am upgrading crm 2011 to crm 2016 onpremise, due to new rendering engine of newer version so many javascript code is not working. Recently getting issue with iframe where I am unable accessing iframe contents using JQuery.
var ccControl = $("#WebResource_ccCheckList").contents().find(":checkbox");
if(ccControl)
{
//Business Logic
}
The element I want to access is an html input with id of 'myChckboxId': Are you Agree ? getting ReferenceError: '$' is undefined Error although $ reference working fine with scripted in IFrame. tried following workaround to fix but not working for me :
1)Put following script on onload.
if (typeof($) === 'undefined'){
var script = document.createElement('script');
script.src = 'ajax.googleapis.com/.../jquery.min.js';
script.async = false;
document.head.appendChild(script);}
2)
$(Xrm.Page.ui.controls.get('WebResource_ccCheckList').getObject()).contents().find(':checkbox').val();
Xrm.Page.ui.controls.get('WebResource_ccCheckList').getObject() is giving me obj but not works with $.
3)
Xrm.Page.ui.controls.get("WebResource_ccCheckList").getObject().contentWindow.document.getElementById('myChckboxId');
Getting Null
Please suggest any alternate approach to resolve the issue.
Thanks