Call javascript function from another javascript webresource

百般思念 提交于 2019-12-06 07:12:28

问题


There is one JavaScript web resource in CRM 2011 called new\_/Script/genericJScript.js. Which contains some functions say, \_retrieveRecord() and \_Context() as below. And I need to call these methods from another JavaScript web resource called new\_/Script/testJScript.js. How can we do this?

if (typeof (MyTest) == "undefined")
{
  MYTEST = { __namespace: true };
}

MYTEST.RESTCALL = {
  _Context: function () {
    ......
  },

  _retrieveRecord: function () {
    ......
  },
};

回答1:


Assuming you include both resources on your form (I am assuming you are doing this from), the following should be valid:

webresource1.js

function HelloWorld() {
  alert('Hello, world!');
}

webresource2.js

//should alert 'Hello, World!' using the method from the other webresource
HelloWorld();



回答2:


I think the answer is simply to call MYTEST.RESTCALL._context()



来源:https://stackoverflow.com/questions/9358675/call-javascript-function-from-another-javascript-webresource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!