lz.BrowserService
Provides access to the browser and player environment

JavaScript: lz.BrowserService

lz.Browser is the single instance of the class lz.BrowserService.

Interface to the browser via the runtime kernel

The lz.Browser service provides access to the browser and player environment. It includes methods to load URLs in the browser, and check the version of the player. For example:

Example 31. Using lz.Browser to launch another browser

<canvas height="140" debug="true">
   <!-- Load the Laszlo site in a new window -->
   <button onclick="lz.Browser.loadURL('http://www.laszlosystems.com/', '_blank')">
     Click me
   </button>
   <script>
     // List the player version
     Debug.write('Player version: ' + lz.Browser.getVersion());
   </script>
 </canvas>
edit

Class Attributes

Name Type (tag) Type (js) Default Category
LzBrowser   lz.BrowserService   readonly
  The browser service. Also available as the global lz.Browser.

Methods

callJS()
lz.BrowserService.callJS(methodname : String, callback : Function, args);
Runs a Javascript method in the browser, optionally returning the result. Note that this feature requires the application to be embedded by the embed-compressed.js library.
Parameter Name Type Description
methodname String Browser javascript method name to execute
callback Function Optional callback function to receive the return value of the javascript call
args    

getAppID()
lz.BrowserService.getAppID();
This function returns the id the app was started with
Returns Type Description
  String The id the app was started with

getInitArg()
lz.BrowserService.getInitArg(name : String);
This function returns the value of a key in the request string that requested the the lzx app. This can be used to communicate server to an lzx app without forcing the app to make a request
Parameter Name Type Description
name String The name of the key whose value to return
Returns Type Description
  String The value for a key that appears in the request to the lps server

getLoadURL()
lz.BrowserService.getLoadURL();
Returns the URL from which the application was loaded.
Returns Type Description
  String the URL the swf was loaded from

getLoadURLAsLzURL()
lz.BrowserService.getLoadURLAsLzURL();
Returns the loadUrl as a new LzURL
Returns Type Description
  lz.URL the URL the application was loaded from, as an LzURL

getOS()
lz.BrowserService.getOS();
Returns information about the operating system

getVersion()
lz.BrowserService.getVersion();
Returns version information about the browser

isAAActive()
lz.BrowserService.isAAActive();
Determines if a screen reader is active and the application is focused @return: True if a screen reader is active and the application is focused

loadJS()
lz.BrowserService.loadJS(js : String, target : String);
Runs Javascript in the browser using a javascript: url, optionally in a target window. Note that Flash limits the javascript string to a maximum of 508 characters. See callJS() for a higher-performance alternative.
Parameter Name Type Description
js String Javascript string to execute
target String Optionally specifies a named frame to display the contents of the URL. By default, the javascript specified in 'js' is executed in the current browser frame .

loadURL()
lz.BrowserService.loadURL(url : String, target : String, features);
Loads a URL in the browser, optionally in a target
Parameter Name Type Description
url String URL to load
target String Optionally specifies a named frame to display the contents of the URL. The document specified by URL is loaded into the current browser frame by default.
features    

makeProxiedURL()
lz.BrowserService.makeProxiedURL(params);
Parameter Name Type Description
params    

setClipboard()
lz.BrowserService.setClipboard(str : String);
Sets the system clipboard to the specified string
Parameter Name Type Description
str String String to set the system clipboard to

showMenu()
lz.BrowserService.showMenu(truefalse : Boolean);
Turns the runtime-specific context menu on or off
Parameter Name Type Description
truefalse Boolean boolean value - true for on, false for off.

urlEscape()
lz.BrowserService.urlEscape(str : String);
[Caution] This method is deprecated
Use encodeURIComponent(string) instead.
Escape a string using URL encoding.
Parameter Name Type Description
str String The string to escape
Returns Type Description
  String An URL escaped string

urlUnescape()
lz.BrowserService.urlUnescape(str : String);
Escape a string using URL encoding.
Parameter Name Type Description
str String The string to unescape
Returns Type Description
  String An URL decoded string

xmlEscape()
lz.BrowserService.xmlEscape(str : String);
Escape special characters in message: & and <.
Parameter Name Type Description
str String The string to escape