...
Let us assume that there is an “OPENEXTERNAL” “OPEN EXTERNAL BROWSER” button in your mobile app. When that button is clicked, Google.com page must be displayed within your mobile app. The following sample code snippet shows the usage that can be written in a listener JS file.
Code Block | ||
---|---|---|
| ||
//* The Thisfollowing function opens the external URL within the hybrid app. * Here, CFEC.CLICK is the Canvas event that can be used to capture the button clicked action. * OPENEXTERNAL is the form item ID for the "OPEN EXTERNAL BROWSER" button. */ this.fm.registerHandler("cbxclick"CFEC.CLICK, "OPENEXTERNAL", function (fm, event, fieldName, value) { var url = 'https://www.google.co.incom/'; var params = { options: "location=yes,hidden=yes", url: url }; var ref = canvas.env.util.browser.openExternal(params); canvas.ref = ref; onLoadStart(ref); onLoadStop(ref); onLoadError(ref); exit(); }); function onLoadStart(ref) { canvas.env.util.browser.onLoadStart(ref, loadStartCallBack); } function onLoadStop(ref) { canvas.env.util.browser.onLoadStop(ref, loadStopCallBack); } function onLoadError(ref) { canvas.env.util.browser.onLoadError(ref, loadErrorCallBack); } function exit(ref) { canvas.env.util.browser.exit(ref, exitCallBack); } function loadStartCallBack() { $('#status-message').text("loading please wait ..."); } function loadStopCallBack() { if (canvas.ref !== undefined) { canvas.ref.show(); } } function loadErrorCallBack() { showAlert("loadErrorCallBackError in loading page."); } function exitCallBack() { showAlert("ExitCallBackClosing external browser."); } |