Now I was searching for some information regarding Javascript and I found some interesting codes. One of these could be used to solve the problem as described above! What about loading javascript files WITH javascript? It is possible by using this script:
var script = document.createElement('script');
script.type = 'text/javascript'; script.src = 'code.js';
document.getElementsByTagName('head')[0].appendChild(script);
When putting this code into the onchange event, this stays readable, does not cost much effort and you wont break the support contract!
Edit:
The script above could give troubles when a function call is made to the javascript file when it is not yet fully loaded. Thanks to Alex for providing this script:
function OnChange()
{
var script = document.createElement('script');
script.language = 'javascript';
script.src = 'MyFunctions.js';
document.getElementsByTagName('head')[0].appendChild(script);
var f = function()
{
if (event.srcElement.readyState == "loaded")
SomeFunction(); // some function from MyFunctions.js
}
script.attachEvent("onreadystatechange", f);
}
// function OnChange()
Update:
Just a bit better readable script:
var script = document.createElement('script');
script.language = 'javascript';
script.src = '/Custom/JavaScript/opportunityOnloadOnsave.js';
script.onreadystatechange = OnScriptReadyState;
document.getElementsByTagName('head')[0].appendChild(script);
function OnScriptReadyState()
{
if (event.srcElement.readyState == "complete")
{
//perform onload scripts
CustomOnLoad(); // some function from your custom js file
}
}