Expand my Community achievements bar.

Check Internet Connectivity

Avatar

Former Community Member
Designer 8.1



Hi,



I have a form, which has a number of image objects linked to url resources.



If the form is opened when there is no internet connection on the machine, the images do not appear, but unlike a web page, there is no x in the corner of the image field to indicate that the image is missing.



I want to run a script that retuns true/false it the internet is available/unavailable. I can then hide the empty image fields and show a text field advising the user that the need to be connected to the internet.



I suspect I need a javascript function that tries to access the internet so that I can capture the error when this fails.



I just don't know what function I can use to test the internet connectivity.



Does anyone have any ideas?



Thanks



James
4 Replies

Avatar

Level 5
Try looking at the app.launchURL method.



You might need to wrap the call such that you launch a well known URL, and close the window very soon afterward on success or failure.



Mark

Avatar

Level 6
Check out the FormCalc post function in the FormCalc documentation. Try using it on initialize of the form to check for connectivity. Let us know if that works out.

Avatar

Former Community Member
Mark,



I can get the app.LaunchURL to fire, but there doesn't appear to be an error returned. The Browser is opened and the error is in the browser. I have a try..catch block but there is nothing for it to catch



function fnGetInternetConnection(){

var e;

try{

// app.launchURL("http://www.google.com", true);

//Post("www.google.co.uk","test");

}catch(e){

xfa.host.messageBox("fnFormatCityTime(): " + e);

}

}



Jared,



How do I catch an error using FormCalc?



Thanks



James

Avatar

Level 6
Good question. I don't know how FormCalc does error handling. I could find no mention of it in the documentation. Even if we could figure that out though, there's another problem with the idea. Acrobat/Reader prompts the user when you use get() or post() to ask permission to access the web site. That makes a lot of sense, since you wouldn't want the form posting your data without the user knowing it. I wonder if the same thing happens with web services.