canOpen


Purpose

Checks if a document (specified by the URL address) is supported by the client device, i.e. if the specified document can be displayed.

Signature

canOpen( url, options, callbacks )

Returns

This method does not return anything.

Parameters

Name Description Type Use
url An URL to the file. Use "undefined" to indicate that the mimeType (from the "options" object below) should be checked. string required
options Configuration passed to the function call. It must contain either url or mimeType parameter. object optional
callbacks Passed to verify whether there is an external application that can open that particular file type. undefined required

The canOpen method's options object looks like in the following example.

{ mimeType, preview, timeout, authenticationType, username, password }
Name Description Type Use
mimeType A MIME type to be checked. If this property is specified, the url must be null or not defined. string optional
preview If set to true, the API will check if a preview of that file type is possible (instead of looking for an external application). This property is supported on iOS only and its default value is "false". boolean optional
timeout A server response timeout (in seconds). It is used only if http(s)-based URL address has been specified. The default value of this property is "60". integer optional
authenticationType Specifies the function's behavior when HTTP basic authentication is requested. The setting's default value is "AUTHENTICATION_ANONYMOUS". Other possible settings are listed in the Constants section of the DocumentViewer article. string optional
username An optional username used when HTTP basic authentication is requested. The value is passed only if authenticationType is set to "AUTHENTICATION_CUSTOM_CREDENTIALS". string optional
password An optional passoword used when HTTP basic authentication is requested. The value is passed only if authenticationType is set to "AUTHENTICATION_CUSTOM_CREDENTIALS". string optional

The canOpen method's callbacks object can be structured as follows:

{
  onResult: function(result) {...},
  onFailure: function(error) {...}
}

The table below lists all callbacks supported by the method.

Name Description Return type
onResult Called when the function finishes without an error. The result parameter passed in this callback is a boolean value specifying whether the file can be opened or not. undefined
onFailure

Called when an error occurs.

The error object contains two fields: code (a numeric value associated with an error) and description (the type of failure). Possible failure types are listed in the Constants section of the DocumentViewer article.

undefined

Related topics

DocumentViewer
Legal notice | Copyright © 2015 and Confidential to Pegasystems Inc. All rights reserved. | Feedback
Advanced...