Reputation: 31
I have created an application in HTML5 and javascript that obviously will run in any browser, but it also can be loaded into another software (other.app) that uses its' functionalities.
I need to create a condition so when my app is loaded in a browser, it will not execute the functions that are referring to other.app.
Example:
function doStuff(){
if(isOtherApp){
doOtherAppFunction();
}
doAllOtherStuff();
}
Is there a way in javascript to find out what application loaded and is execution my application?
Hope this is clear enough. Thanks in advance for any suggestions.
Upvotes: 0
Views: 427
Reputation: 943651
There isn't a reliable way, but you can check a property provided by the JavaScript engine and test if it exists or has a certain value.
If your application is providing extra JavaScript methods and you only want to call them if they exist, then you can just test for their existence:
if (window.nonStandardFeature) {
window.nonStandardFeature();
}
Upvotes: 2