external javascript files crm 4.0 RRS feed

  • Question

  • Which is the best way to use external javascript files. I heard about calling them in global.js

    I want to be able to use external .js files instead of putting the code in the form. Plus I want to be able to have a .js file with all common functions defined and to be able to call them in all other .js files

    Wednesday, March 2, 2011 10:52 AM


All replies

  • function load_script(url) {
      var x = new ActiveXObject("Msxml2.XMLHTTP");
      x.open('GET', url, false); x.send('');

    add above code to form OnLoad event.


    your xx.js should be wrapped by :

    hope this helps

    Wednesday, March 2, 2011 11:04 AM
  • the problem with this is that old script is cashed, so I have to clean the cash everytime I make a change in the script.
    Wednesday, March 2, 2011 11:31 AM
  • You could also do what you want to do in javascript in an iframe and interact with the CRM form using cross-frame scripting.  You can enable cross frame scripting in the properties of the Iframe.  I would not add javascript to global.js though for this.

    Jamie Miley
    Wednesday, March 2, 2011 2:54 PM
  • The load_script method should be avoided though if possible as it ironically, causes a caching problem.  It is outlined here.


    Jamie Miley
    Wednesday, March 2, 2011 2:57 PM
  • why you do not use "refresh from server every time" setting in your browser? 
    Thursday, March 3, 2011 1:20 AM
  • i think the cache is OK for deploy. 

    maybe we need to clean cache manually several times. 

    but i think it's OK. 


    the problem is the efficiency of eval function. 

    Thursday, March 3, 2011 1:21 AM
  • A solution that attempts to overcome caching and avoids eval:



    --pogo (pat)
    Thursday, March 3, 2011 1:36 AM