Problem with External JS Files


John Clarke
I have created 2 external JS Files. The first is called BaseClass.js and is a base class used to implement an inheritance mechanism. The second is called Config.js. Both of these have been added to the File Manager and have had their IsContent flag set to true.

Config.JS contains the following code

If I add the following line to WebExtContent it displays the message on the Console

However, if I add the following code to the Show Event of the view nothing happens.

So my question is how can I get this same external JS file to work in both the WebExtContent and in the event on the view ?

Thanks in advance

DecSoft

Hello John,

The point is that the app views and the WebExtensions content and background scripts works in different leagues: you already know that we can communicate both leagues, but, we can't share certain stuff like you wanted here in this post. I think we have at least three possible solutions or workarounds that we can do:

1º Duplicate the "Config.js" file, named one "AppConfig.js" and other "WebExtConfig.js", and use the app's Files Manager to properly add these scripts for the app and for the WebExtension.

2º Copy the contents of the "Config.js" file and place it in a script which are used by the app and by the WebExtension: maybe you can directly copy the contents of the "Config.js" file in the app's Mounted event and some of the WebExtension event... or just leave a file for the WebExtension.

3º Use a web served "Config.js" file, which you can add by his URL using the app's Files Manager, maybe with some different "query", since in other case, that is, using the same URL, probably we can't use it for both the app's views and the WebExtension.

In any case we are not sharing the file, due to the fact that I refer in the first paragraph of this post: we are talking about different contexts that cannot share stuff in this manner. So I think you can chooose one of the above possible approachs. Why I will do? Since apparently what the "Config.js" file establish certain Javascript object to be extended, I think that duplicate the "Config.js" can be enough, in order to provided that base object in both the app's views and the WebExtension contexts.


Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.

Este sitio utiliza "cookies" útiles para almacenar sus preferencias.

Bien. Ocultar esta nota. Obtener más información.