locked
Check for internet connection in Office task pane apps. RRS feed

  • Question

  • I have made a task pane office app which involves the usage of internet(of course). For the successful working, i need to check whether the device is connected to the internet otherwise, if not, the app would crash.

    I have checked other questions in MSDN but being a novice, can't relate to my situation.

    Could you please tell the procedure and code involved behind this process.

    So, that the app informs the user that it isn't connected to the internet and hence can't continue.

    Thank You!

    Saturday, December 14, 2013 11:06 AM

Answers

  • Hi,

    Here is a sample to check the internet connection using JQuery:

    Add a JavaScript function ( http://msdn.microsoft.com/en-us/library/ie/ms534307(v=vs.85).aspx):

    $(document).ready(function () {
                var online = window.navigator.onLine;
                if (!online) {
                    $('#Msg').html('Can not connect to the internet!');
                }
                else {
                    $('#Msg').html('Connect to the internet successfully!');
                }
            });
    

    Add below code in html body:

    <div id="Msg"></div>

    It works fine in IE browser.




    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by YashVj Monday, December 16, 2013 10:34 AM
    Monday, December 16, 2013 10:22 AM