CrossBrowdy - Basic tutorial


Exiting the app and address management

When using an app (NW.js, Electron, Apache Cordova, PhoneGap, WeChat / Weixin, etc.), we can use CrossBrowdy to try to close it and exit:

	//Exits the app:
	CB_Client.exit(); //By default, it will use internal fallbacks and workarounds if standard methods fail.

Note that the CB_Client.exit method can use some fallbacks and workarounds internally to try to close the app when standard methods fail. This can be useful when it is running on web browsers and other platforms.

Here are some examples of redirection and address management:

	//Redirect the app:
	CB_Client.redirectTo(""); //Redirects to "".
	CB_Client.redirectTo("", "data2=value2&data3=value3"); //Redirects to "".
	//Checks whether it is running locally (using the "file:" protocol):
	if (CB_Client.isRunningLocally()) { CB_console("It is running locally"); }
	else { CB_console("It is NOT running locally"); }
	//Knowing the current address (location):
	var currentLocation = CB_Client.getLocation(); //It should return the entire location, including the file if it is present (for example, "").
	var currentLocationWithoutFile = CB_Client.getLocationWithoutFile(); //It should return the location without the current file (for example, "").

Note that many of the functions support a "mindIframes" parameter to decide whether to have or not into account that it could be running inside one or more IFRAME elements. Without setting this parameter, by default it will use the value set on the CB_Configuration.CrossBase.MIND_IFRAMES constant.

Check the API documentation to read more about the CB_Client static class.

Go back to Guides & Tutorials