Answered by:
CRM 2011: Javascript: Object doesn't support property or method 'setSrc'

Question
-
Hi there,
I've a simple Javascript which sets an image in an iFrame on change of a field. Here is the code used:
Xrm.Page.ui.controls.get("IFrame_Name").setSrc('/WebResources/SampleImage.png'); Object doesn't support property or method 'setSrc' Tried this as well but no luck Xrm.Page.getControl("IFrame_Name").setSrc('../WebResources/NoImage.png'); Object doesn't support property or method 'setSrc'
Any idea about this?
Thanks,
AbhiThursday, November 7, 2013 11:19 AM
Answers
-
Tried using Jquery like this.
$(document).ready(function() {
$(“#<attributename>”).attr(“scr”,”<resourcePath>”);
});
And this resolved the problem. Note than we need to include the JQuery library first in order to use above code.
Thanks,
AbhiMonday, December 16, 2013 6:31 PM
All replies
-
Below link suggests that this could be because IFrame is still loading:
http://social.microsoft.com/Forums/en-US/c7cca5eb-2e73-46b2-aa36-4505dd2b948f/how-to-change-the-iframe-url-at-form-onload-event-in-ms-crm-2011?forum=crmdevelopment- Arvind
Thursday, November 7, 2013 12:14 PM -
Hi Arvind,
In my case, I've checked that the object is available while debugging but setSrc() is not available and hence the error. Not sure, why this is happening.
Thanks,
AbhiThursday, November 7, 2013 12:31 PM -
Tried using Jquery like this.
$(document).ready(function() {
$(“#<attributename>”).attr(“scr”,”<resourcePath>”);
});
And this resolved the problem. Note than we need to include the JQuery library first in order to use above code.
Thanks,
AbhiMonday, December 16, 2013 6:31 PM