Hello guest! Login or Register
Construct 2 r90

Released Friday, May 11, 2012 at 2:01:09 PM

28mb for Windows XP, Vista & 7

Free Download
Download Manual

Coming Soon

Browser


The Browser object accesses features of the web browser running the HTML5 game. It also switch to and from fullscreen mode, detect if the game is updating in the background, and determine if the page is visible.

Security limitations sometimes prevent browser actions. For example, the window Close action can only be used when the window was created by a javascript window.open call.

Browser conditions


Cookies enabled
True if the user has cookies enabled in their browser. (Typically it is rare for them to be disabled since many web sites rely on cookies to work properly.)

Is online
True if the browser currently has an active connection to the internet. Construct 2 games can work offline - see Offline games for more information.

On went online
On went offline
Triggered if the connection to the internet is becomes available or unavailable during the running of the game. This is common on mobile devices which may be moving in and out of signal areas. The Is online condition also changes to reflect the connection status.

On menu button
Currently only supported when exporting to PhoneGap
Triggered when the user presses the device's 'Menu' button. Note not all devices have this button, e.g. iOS devices only have a 'Home' button.

On search button
Currently only supported when exporting to PhoneGap
Triggered when the user presses the device's 'Search' button. Note not all devices have this button, e.g. iOS devices only have a 'Home' button.

Is downloading update
True if the game is running from cache, but downloading an updated version in the background. This can be used to implement a simple auto-updater. See Offline games for more information.

On update ready
Triggered when the game is running from cache, but an updated version has finished downloading in the background. If the user is still on the game's menu or title screen, you may wish to prompt them to refresh the page (or just do it automatically) so the new version is loaded. See Offline games for more information.

Is fullscreen
True if the browser is running in fullscreen mode.

Page is visible
True if the page the HTML5 game is running on is currently visible. The page counts as hidden if the window is minimised, the page is in a different tab to the one being viewed, or on a mobile device when the app goes in to the background. When the page is hidden the game automatically pauses.

On suspended
On resumed
Triggered when the page's visibility changes, or when a mobile app is going in to the background or foreground. When invisible or in the background the app is suspended: all events stop running and all audio is muted.

Browser actions


Go back
Go forward
Move through the browser navigation history as if clicking the Back and Forward buttons on the browser.

Go home
Navigate to the browser's set homepage.

Go to URL
Navigate to a given URL. Note this uses the same window/tab as is showing the HTML5 game, so this action will end the game.

Open URL in new window
Navigate to a given URL in a new window (or tab if the browser settings override). This continues to run the HTML5 game in the old window or tab.

Reload
Force the page to refresh. This effectively restarts the game.

Alert
Bring up a simple 'alert' message box.

Blur
Unfocus the browser window.

Cancel fullscreen
Return to windowed mode if the browser is currently in fullscreen mode.

Close
Close the current window, if the script has permission to do so.

Focus
Focus the browser window.

Request fullscreen
Request that the browser enter fullscreen mode. Note the browser may ignore this request unless the action is in a user-initiated event, such as a mouse click, key press, touch event or button press. There are three different fullscreen modes that can be entered:
Center - center the game viewport in the fullscreen view
Stretch (crop) - extend the game viewport to fill the fullscreen view
Stretch (scale) - scale (zoom) the game viewport to fill the fullscreen view
The latter two options correspond to the Fullscreen in browser project property. For more information see supporting multiple screen sizes.

Browser expressions


Langage
Get the browser's current language setting, e.g. en-US.

Name
Get the name the browser reports for itself. This may be inaccurate for backwards compatibility reasons, e.g. Google Chrome reports its name as Netscape.

Platform
Get the current platform the browser reports itself running on, e.g. Win32 for Windows.

Product
Get the product the browser reports for itself. This may be inaccurate for backwards compatibility reasons, e.g. Google Chrome reports its product as Gecko.

UserAgent
Return the full user agent string for the browser, e.g. Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63.

Vendor
Get the vendor the browser reports for itself, e.g. Google Inc. for Google Chrome.

Version
Get the version the browser reports for itself as a string. This can simply be a subset of the user agent string.

Title
The current HTML document's title.

Domain
The current domain, e.g. scirra.com.

Hash
The string after the hash at the end of the URL, including the hash. For example, if the current URL is http://scirra.com/mygame/index.html#teapot, this returns #teapot.

PathName
The path relative to the domain in the URL. For example the path name of http://scirra.com/mygame/index.html#teapot is /mygame/index.html.

Protocol
The current protocol, usually either http: or https:.

QueryParam
Return a query string parameter by name. For example, if the URL ends with index.html?foo=bar&baz=wan, QueryParam("foo") returns bar and QueryParam("baz") returns wan.

QueryString
Return the full URL query string including the question mark. For example, if the URL ends with index.html?foo=bar&baz=wan, this returns
?foo=bar&baz=wan.

Referrer
Get the previous page that linked to this page, if any.

URL
Get the complete current URL in the browser address bar, including the protocol.

Previous Entry
Audio
Next Entry
Button

Feedback on this page
How useful was this page for you?
Do you have any suggestions for this page?