Browser -> isOnline always returns true

0 favourites
  • 3 posts
From the Asset Store
This Girls Game allows young fashionistas to develop their taste and skills as a fashion designer.
  • Problem Description

    When previewing in Chrome, Firefox and mobile compiled with Intel XDK the behaviour Browser -> is online always returns true. On IE it works fine.

    Description of Capx

    A very simple test of the behaviour in question. Here's the content:

    Steps to Reproduce Bug

    • Step 1 Run the capx.
    • Step 2 Disconnect the internet.

    Observed Result

    The text label still says "connected". Apparently the condition returns true even without the connection.

    Expected Result

    The condition should return false, so that the else condition would fire and the label should change to "disconnected."

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Internet Explorer: (NO)

    Operating System and Service Pack

    Windows 8.1

    Construct 2 Version ID

    r196.2

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This is not a C2 bug. It is simply returning the navigator.onLine property, which as the MDN describes has a complicated definition: https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine.onLine

    The spec says:

    [quote:2pawdroz]The navigator.onLine attribute must return false if the user agent will not contact the network when the user follows links or when a script requests a remote page (or knows that such an attempt would fail)...

    Browsers interpret this differently. Some browsers only return false if they are explicitly put in to "offline mode", others only if they are not connected to any LAN, and perhaps others if they cannot reach some fixed server on the Internet (say google.com). It's surprisingly difficult to define "online". For example if you can access company intranet websites, but not outside internet websites, are you online (in the sense that you can access remote pages) or offline (in the sense that you can't access other servers elsewhere)?

  • I see. Indeed I ran into some difficulties in the past because my apps 'thought' they were online when connected to intranet. I guess I'll write a plugin that pings Google or something like that. Thank you for the info Ashley.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)