Error Handling
Technical Document
There are two way's to handle errors. IntraLaunch can display an error dialog box itself, or pass back an return code of '0' or '1' depending on whether the previous operation that it previously attempted was a success or not. Both are demonstrated below. The first example uses the showerrors: 'true' parameter. As you can see the program: 'notpad.exe' is spelt incorrectly, hence the error. Settings showerrors: 'false' will stop IntraLaunch from opening it's own error dialog box and leave you to do something via Javascript such as forward the user to a support page which is shown in the second example.
<html> <script src="https://code.jquery.com/jquery-2.2.3.min.js"></script> <script language="JavaScript" type="text/javascript"> var $jQuery = jQuery.noConflict(); </script> <script type="text/javascript"> jQuery(document).ready(function() { jQuery("#notepad_link").on("click", function (event) { event.preventDefault(); // Recommended to stop the link from doing anything else document.dispatchEvent(new CustomEvent('funcIntraLaunch', { 'detail': { task: 'run', program: 'notpad.exe', workingfolder: '', switches: '', windowstate: 'max', showerrors: 'true' } })); }); }); </script> <body> <a href="#" id="notepad_link">Open notepad</a> </body> </html>
IntraLaunch will return 'run' as part of its return code which
signifies the return code is from a previous execution operation. As opposed
to "dir", "deletefile", "deletefolder" which are used in file management and do not
apply here. Note all IntraLaunch objects on the page will call funcIntraLaunchLastOpResult when they
execute. To help differentiate which object is returning what code you can pass
an identifier (typically the HTML element's ID) through and check for it
on return (see responseIntraLaunchDOMElement) using the options: 'some_id' parameter
as shown below.
<html> <script src="https://code.jquery.com/jquery-2.2.3.min.js"></script> <script language="JavaScript" type="text/javascript"> var $jQuery = jQuery.noConflict(); </script> <script type="text/javascript"> jQuery(document).ready(function() { jQuery("#notepad_link_js").on("click", function (event) { event.preventDefault(); // Recommended to stop the link from doing anything else document.dispatchEvent(new CustomEvent('funcIntraLaunch', { 'detail': { task: 'run', program: 'notpad.exe', workingfolder: '', switches: '', options: 'notepad_link_js', windowstate: 'max', showerrors: 'false' } })); }); // Handle all IntraLaunch responses jQuery.extend ({ funcIntraLaunchLastOpResult: function (responseIntraLaunchLastOpType, responseIntraLaunchDOMElement, responseIntraLaunchDataSet) { // If a program failed to run if (responseIntraLaunchLastOpType == "run" && responseIntraLaunchDOMElement == "notepad_link_js") { if (responseIntraLaunchDataSet == "0") { alert('Failed to open the program or document.'); } else if (responseIntraLaunchDataSet == "1") { alert('You have fixed the problem.'); } } } }); }); </script> <body> <a href="#" id="notepad_link_js">Open notepad</a> </body> </html>