Skip to content

Latest commit

 

History

History
58 lines (42 loc) · 2.09 KB

browser.md

File metadata and controls

58 lines (42 loc) · 2.09 KB

The package browser groups the built-in Brython-specific names and modules

browser.alert(message)

a function that prints the message in a pop-up window. Returns None

browser.bind(target, event)

a function used as a decorator for event binding. Cf. section events.

browser.confirm(message)

a function that prints the message in a window, and two buttons (ok/cancel). Returns True if ok, False if cancel.

browser.console

an object with methods to interact with the browser console. Its interface is browser-specific. It exposes at least the method log(msg), which prints the message msg in the console

browser.document

an object that represents the HTML document currently displayed in the browser window. The interface of this object is described in section "Browser interface"

browser.DOMEvent

the class of DOM events

browser.DOMNode

the class of DOM nodes

browser.is_webworker

boolean indicating if the current script is executed in a Web Worker

browser.load(script_url)

Load the Javascript library at address script_url.

This function uses a blocking Ajax call. It must be used when one can't load the Javascript library in the html page by <script src="prog.js"></script>.

The names inserted by the library inside the global Javascript namespace are available in the Brython script as attributes of the window object.

browser.prompt(message[,default])

a function that prints the message in a window, and an entry field. Returns the entered value ; if no value was entered, return default if defined, else the empty string

browser.run_script(src[, name])

this function executes the Python source code in src with an optional name. It can be used as an alternative to exec(), with the benefit that the indexedDB cache is used for importing modules from the standard library.

browser.window

an object that represents the browser window (see the MDN documentation)