webArea
The webArea class provides an interface to manage properties and actions of webArea widget.
Hierarchy
The webArea class is available via the form class through the WebArea interface.
This.form:=cs.form.new(This)
...
This.myWidget:=This.form.WebArea("myWebArea")
...
This.myWidget.open(File("/RESOURCES/Index.html"))
This class is, more generally, available from the cs class store, or cs.ui class store if you use the UI component.
Form.myWidget:=cs.ui.webArea.new("form object")
Form.myWidget.open("https://4D.com")
📌 Conventions
- To simplify the distinction between form objects and object type, this documentation uses the term “widget” for all form objects, whether static (a line, a rectangle…) or not (a button, a subform…).
- All functions that return
Thisreturn the current widget object and can include one call after another.
cs.webArea.new()
cs.webArea.new ( name : Text) : cs.webArea
cs.webArea.new ( name : Text ; data : any) : cs.webArea
cs.webArea.new ( name : Text ; data : any ; parent : Object) : cs.webArea
cs.webArea.new ( ) : cs.webArea
| Parameter | Type | Description | ||
|---|---|---|---|---|
| name | Text | → | Widget name | |
| data | Text | Collection | → | allowed URLs |
| parent | cs.form |
→ | form object containing the widget |
|
| result | cs.webArea | ← | New cs.webArea |
Description
cs.webArea.new() creates & returns a new instance of the class.
- When the
webArea*widget is instantiated without passing thedataparameter, a default filter is installed allowing only blank HTML documents (about:blank). You can modify URL filtering with the.allow()&.deny()functions. - The optional
parentparameter is thecs.formobject containing the widget. This parameter is automatically set if instantiation is performed via a form widget instantiation function of thecs.formclass. - If the
nameparameter is ommited, the constructor use the result of OBJECT Get name (Object current )
Important:
- This class inherit from the
widgetclass- Omitting the widget name can only be used if the constructor is called from the object method.
- The URL filtering applies to any request to change the primary URL of the page, whether from the user, javascript code or 4D code, except for the
.open()function and URLs starting with “javascript:”. To disable URL filtering, call the.allow()function, passing an empty string or the value*..
Summary
Inherited Properties & Functions
Inherited properties and functions are described in the parent classes:
Properties
| Properties | Description | Type | Writable |
|---|---|---|---|
| .canBackwards | A previous URL is available in the URL sequence opened in tWeb area | Boolena |
x |
| .canForwards | A following URL is available in the URL sequence opened in tWeb area | Boolena |
x |
| .content | HTML code of the page being displayed in the Web area | Text |
✓* |
| .errors | Descriptions of errors encountered since class instantiation of the class | Collection |
x |
| .filterdURLs | URLs that have been filtered in the Web zone since the instantiation of the class | Collection |
x |
| .lastError | Description of the last error encountered if any | Text |
x |
| .loaded | URL address of the page displayed in the Web area | Text |
x |
| .success | Result of the last function execution | Boolean |
x |
| .url | URL address of the page displayed in the Web area | Text | 4D.File |
✓ |
* As security is tightened in modern browsers, there are more and more restrictions on modifying page content “on the fly”. A more reliable approach is to use the function setContent()
Functions
| Functions | Action |
|---|---|
| .allow ( data {; allow }) | Removes URL from URL filtering |
| .back ( ) | Loads the previous URL in the sequence of URLs opened into the Web area |
| .backMenu ( ) | Displays a context menu containing a list of previous URLs in the URL history of the Web area, then loads the item if one is selected |
| .clear ( ) | Loads a blank page into the Web area |
| .deny ( data ) | Appends URL to URL filtering |
| .evaluateJS ( code {; typeReturn }) | Executes, in the Web area, the JavaScript code passed in code and returns the result |
| .executeJS ( jsFunction }) | Executes, in the Web area, the JavaScript function jsFunction |
| .forward ( ) | Loads the next URL in the sequence of URLs opened into the Web area |
| .forwardMenu ( ) | Displays a context menu containing a list of next URLs in the URL history of the Web area, then loads the item if one is selected |
| .getWebEngine ( ) | Detects which web rendering engine is being used for the Web Area |
| .isLoaded ( ) | Returns True if the current URL is equal to the url property of the Web area |
| .load ( file ) | Loads a file into the Web zone after processing 4D tags, if required |
| .open ( data ) | Loads an URL passed into the Web area |
| .refresh ( ) | Reloads the current URL in the Web area |
| .showInspector ( ) | Opens a web inspector for the Web area |
| .setContent ( ) | Safely modify page content (the content is saved into a temporary file then open) |
| .stop ( ) | Stops loading the resources of the current URL of the Web area |
| .zoom ( in ) | Increases, if in = True, decreases otherwise, the size of the contents displayed in the Web area |
| .zoomIn ( ) | Increases the size of the contents displayed in the Web area |
| .zoomOut ( ) | Reduces the size of the contents displayed in the Web area |
.allow()
.allow ( allowed {; allow })
| Parameter | Type | Description | |
|---|---|---|---|
| allowed | Text | Collection | ← | URL(s) to be allowed into the Web area |
| allow | Boolean | ← | Allow or not |
Description
Removes the URL or all URLs in a collection from URL filtering, for the Web area.
- If the
allowparameter is omitted,allowwill take the default value, i.e. True.
This optional parameter can be useful for calling filtering or not depending on the value of a test.
Example
Form.myWidget:=cs.ui.webArea.new("form object")
Form.myWidget.allow("https://4D.com";$lang="en")
Form.myWidget.allow(https://fr.4d.com";$lang="fr")
. deny()
.deny ( denied })
| Parameter | Type | Description | |
|---|---|---|---|
| denied | Text | Collection | ← | URL(s) to be denied into the Web area |
Description
Appends the URL or all URLs in a collection to URL filtering, for the Web area.
.open()
.open ( url )
.open ( file )
.open ( )
| Parameter | Type | Description | |
|---|---|---|---|
| url | Text | ← | URL to be loaded into the Web area |
| file | 4D.File |
← | File to be loaded into the Web area |
Description
Loads an URL into the Web area.
If the url text parameter is passed, the url will be used.
Some “special” urls are supported:
- “internal” to open the starting HTML page of current Web server (the function retrieve the current port used)
- “localhost” which will be translated as ‘127.0.0.1’ on macOS where, in some cases, using ‘localhost’ gives the error -30 ‘Server unreachable’.
- ””, an emptyy string to laod
about:blank
If a 4D.File is passed as parameter, the url loaded will be “file:///”+ the path of the file.
📌 In all cases, the url is automatically allowed if nay.