IFrame src can be set on Form Load event, but this technique not work all time as On Load can be complete before loading IFrame. In this case, IFrame Url set to its default value.
The work around is to set IFrame Src in IFrame Event Handler on 'readystatechange' event.
So, add webresource library on form and register the function on IFrame event handler to set the Src.
In below code, I have register IFrame function on IFrame event handler. Now my IFrame Url set successfully.
/// <reference path="XrmPageTemplate.js" />
/// <reference path="AWXRMLibrary.js" />
function IFrame() {
var id = Xrm.Page.data.entity.getId();
var iFrame = Xrm.Page.getControl("IFRAME_StudentAttendance");
// var iframe = Xrm.Page.ui.controls.get("IFRAME_StudentAttendance");
//var url = "/ISV/Attendance Grid/UMT.AttendanceGrid.aspx?LectureId=" + id;
var setUrl = "http://117.102.10.101:8001/UMT.AttendanceGrid.aspx?LectureId=" + id;
var url = iFrame.getSrc();
if (url.indexOf("blank") != -1) {
iFrame.setSrc(setUrl);
}
//iframe.setSrc(url);
}
#AW CRM Consultant Maison Consulting & Solutions