Livecode Wiki
Advertisement

The browser widget creates a Chromium browser windows inside our program.

Technical[]

Livecode uses the CEF (Chromium Embedded Framework) to create it. On Linux the command used by livecode is

/opt/livecode/livecodecommunity-9.0.0-dp-4.x86_64/libbrowser-cefprocess --no-sandbox --lang=en-US --log-file=/opt/livecode/livecodecommunity-9.0.0-dp-4.x86_64/debug.log --log-severity=disable --resources-dir-path=/opt/livecode/livecodecommunity-9.0.0-dp-4.x86_64/Externals/CEF --locales-dir-path=/opt/livecode/livecodecommunity-9.0.0-dp-4.x86_64/Externals/CEF/locales

You can see all option with:

 set the url of widget "browser" to "chrome://help/"

Messages[]

  • browserDocumentLoadBegin pUrl: The browserDocumentLoadBegin message is sent to the widget's script object when a new document begins to load in the browser. This will happen whenever the browser navigates to a new page. The pUrl parameter contains the URL of the loading document.
  • browserDocumentLoadComplete pUrl: The browserDocumentLoadComplete message is sent to the widget's script object when a new document has completed loading in the browser. The pUrl parameter contains the URL of the loaded document.
  • browserDocumentLoadFailed pUrl, pError: The browserDocumentLoadFailed message is sent to the widget's script object when a new document has failed to load in the browser. The pUrl parameter contains the URL of the document, and the pError parameter gives the reason for the failure.
  • browserFrameDocumentLoadBegin pUrl: The browserFrameDocumentLoadBegin message is sent to the widget's script object when a new document begins to load in a frame of the browser. This will happen whenever the browser navigates to a new page with multiple frames. The pUrl parameter contains the URL of the loading document
  • browserFrameDocumentLoadComplete pUrl: The browserFrameDocumentLoadComplete message is sent to the widget's script object when a new document has completed loading in a frame of the browser. The pUrl parameter contains the URL of the loaded document.
  • browserFrameDocumentLoadFailed pUrl, pError: The browserFrameDocumentLoadFailed message is sent to the widget's script object when a new document has failed to load in a frame of the browser. The pUrl parameter contains the URL of the document, and the pError parameter gives the reason for the failure.
  • browserNavigateBegin pUrl: The browserNavigateBegin message is sent to the widget's script object when the browser begins navigation to a new page. This can be triggered by launching a URL in the browser, or clicking a link within the browser. The pUrl parameter contains the URL of the new page.
  • browserNavigateComplete pUrl: The browserNavigateComplete message is sent to the widget's script object when the browser successfully navigates to a new page. The pUrl parameter contains the URL of the new page.
  • browserNavigateFailed pUrl, pError: The browserNavigateFailed message is sent to the widget's script object when the browser has failed to navigate to a new page. The pUrl parameter contains the URL of the new page, and the pError parameter gives the reason for the failure.
  • browserProgressChanged pURL,pProgress: Sent when the load progress of the current document changes. pProgress is the percentage of the document loaded (0-100).
  • browserUnhandledLoadRequest pUrl: the browserUnhandledLoadRequest message is sent to the widget's script object when the browser is unable to load a URL, typically due to an unrecognised URL scheme. The pUrl parameter contains the URL of the unhandled request.

Properties[]

  • allowUserInteraction: you can set to true or false, whether the browser responds to user interaction.
  • HScrollbar
  • isSecure: if it's an encrypted connection
  • HTMLText
  • javascriptHandlers: it's a line separated list of names of handlers that are available to the javascript in the loaded page. For example this code:
on myJSHandler pMessage, pValue
  answer "the browser says:" & pMessage & " values " & pValue
end myJSHandler
set the javascriptHandlers to "myJSHandler"

Now inside the web page this javascript code works:

liveCode.myJSHandler("myMessage", 12345);

In the end it creates a javascript global livecode object. Warning: Setting the javascriptHandlers property gives JavaScript running within the Web browser permission to execute parts of your application through the handlers you choose to expose. If using this feature, make sure that you have complete control over the webpages which you load into the browser widget, and consider using HTTPS to ensure that third-parties cannot inject malicious code into them.

  • URL: the address to load
  • userAgent: A suitable HTTP user agent string. if empty the default user agent is like:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36
Advertisement