function load_script(url) { var x = new ActiveXObject("Msxml2.XMLHTTP"); x.open('GET', url, false); x.send(''); eval(x.responseText);}load_script("/isv/javascript/jquery.min.js");load_script("/isv/javascript/xx.js");
Reading function load_script is actually very simple. It is just a Javascript file loaded with ajax.
In fact, eval is used to execute external js Code.
This method causes code to be cached, and some people on the Internet have pointed out that eval is very inefficient: http://mscrm4ever.blogspot.com/2009/04/crm-form-script-loader.html
In fact, the cache is normal, which can avoid code loading every time, but it is slightly inconvenient during development.
We can solve the cache problem as follows:
load_script("/isv/javascript/xx.js?"+Math.random());
But remember to remove Math. random () after the development is complete ()
So how should I write in xx. js?
(Function () {// TODO}) (); // or (function ($) {// TODO}) (jQuery );
This code is also called JavaScript self-executed code.
----------------- Beautiful split line ---------------------
Get the lookup field in ms crm:
// Get the field that fired the event.var oField = event.srcElement;// Validate the field information.if (typeof(oField) != "undefined" && oField.DataValue != null){var dd = oField.DataValue;if(dd[0] != 'undefined'){ var id = dd[0].id; //TODO }}
Note that the retrieved DataValue is actually an Array (Array ).