Sciter Architecture
Sciter is not using DOM model like W3C DOM as we have found it too complicated (76 different classes, sic!).
DOM and Window classes
Sciter provides following 8 DOM and Window specific classes accessible in script:
- Element - DOM element. All HTML elements including document(root), frame, inputs, etc. are Element's in the Sciter.
- Attributes - collection of named attributes of the html element.
- Style - collection of style attributes applied to the element.
- Image - image object. Represents bitmap image. You can draw on the image using Graphics methods.
- Graphics - object wrapping drawing primitives. You can draw on surface of any Element and Image in the Sciter.
- View - represents Sciter window. Main Sciter window and Dialog are views.
- Event - represents current UI event.
- Sciter - is a global object holding Sciter application specific methods.
View, document, frame and the root element.
Top level windows represented by the View objects in the Sciter. Main windows of Sciter.exe application or client area of X-Sciter.dll sandbox window are views. Dialog windows also have views assosiated with them.
Each view has root property - this is a root element of the loaded document. Root element in the Sciter is <html> element of the loaded document and there is no dedicated Document class. Document is really an element tree - <html> element and its children.
Frames and framesets.
Frames and framesets are also ordinary DOM elements. <frame> element has single child element - <html> element of the document loaded into it. parent property of the root element of the document loaded in the frame refer to the <frame> element this document loaded into. Simple as it is.
Frames (<frame> elements) in the Sciter can appear in any part of the HTML (not only in <frameset>) so there is no difference between <frame> and <iframe> in the Sciter. Moreover any block element like <div> can be declared as a <frame> by declaring style="behavior:frame" for it.
Element object has method load that allows to (re)load content of any element and <frame> from external source - url or stream (including in-memory dynamic stream). So there is not too much difference between block element like <div> and frames in the Sciter. Use frames when you need to isolate different style systems or scripts on the same screen.
The same approach is used with <frameset>s - they are plain DOM elements and may appear at any place where block elements are acceptable. <frameset> can contain not only <frame> elements but any block elements thus <frameset> in the Sciter is a convenient way to define container with splitters. Morever any block element can be transformed into the frameset by declaring behavior:frameset in its style declaration.
Script evaluation.
Sciter knows and interprets only tiscript fragments and files. To include script block in the document use follwing elements:
<script type="text/tiscript" src="url-to-script-file" /> or for inline script inclusion:
<script type="text/tiscript"> // script statements... </script>
Script execution
Sciter executes scripts as a last step of document loading - after </html> tag is being parsed. So at the moment of any script execution DOM is established and scripts can refer to it. Thus there is no onLoad event at all - script execution is occurs at the "onLoad".
Global namespace. view and self objects.
Document (root node of the document - <html>) establishes namespace for script execution so following global function declaration:
<script type="text/tiscript"> function foo() { ... } </script>
defines in fact method attached to the root node of the document where this script is executed. You can call as global function foo(); or as a method of special self object self.foo();
self in the Sciter is a global variable representing root element of the loaded document.
|