Category: Script Library
htmlPrompter
htmlPrompter is a helper function to display html formatted output in the system browser. It looks like a simple popup that uses the system's web browser. As the name implies, it displays html formated text.
This helper is used as the main interface of the scriptHandler and the compareScript applications.
The htmlPrompter creates a temporary directory in the script access folder that contains the display data. This directory has to be deleted by hand. It's called .htmlPrompter and is a hidden directory. It contains a README file as well that explains that the directory can be deleted.
Usage
It is recommended to keep the scriptHandler script in the Scripts form. But if one
document.getFormNamed('Scripts').runScriptNamed('htmlPrompter');
htmlPrompter(title, body, params);
With:
- title (text): page title
- body (html): page content
- params (dictionary): optional configuration parameters. They only need to be set if used.
- raw (boolean): Set to true if body contains the entire page source. The default page structure is bypassed.
- cancelButton (text): Replacement text for the cancel button
- cancelCallback (tfp url): TapForms Pro URL scheme script link
- okButton (text): Replacement text for the okay button
- okCallback (tfp url): TapForms Pro URL scheme script link
- filename (text): Define the filename to be used
- planned:
- theme (dark|light): Sets the display them. Defaults to dark
- outputDir (path): Define output directory to be used
Examples:
With the raw option, htmlPrompter doesn't do any formatting and displays the given code as is. This means there is no popup title nor a close button.
htmlPrompter('',
'<h1 style="color:red;">Lorem ipsum dolor sit amet</h1>',
{'raw': true}
);
This is the typical use where a title and some body text are provided:
htmlPrompter('Export HTML Handler Setup',
'<div style="text-align:center;">just some text</div>'
);
Following example shows how additional parameters are provided as a dictionary:
htmlPrompter('Export HTML Handler Setup',
`<code>function createHeader(title, content, params){}</code>`,
{
'cancelButton': "Gone",
'cancelCallback': "tfp://frm-xxxx...",
'okButton':'Yeah, all good',
'okCallback': "tfp://frm-xxxx...",
'filename': "test.html",
}
);
Limitations
Due to the nature of using a web browser and TapForms Pro URL scheme interface, the browser's window may not close all the time. The output directory has to be cleared by the user.
Installation
The htmlPrompter script is installed using the scriptHandler script about which you can learn more over here. It is installed in the Scripts form.
Dependencies
none
ChangeLog
Link to ChangeLog
Author
- Daniel Leu, info@danielleu.com
Do you like this script? Are you using it? Please consider supporting me by buying me a coffee!
Thanks!
Last modified: Apr 24, 2025 6:27:00 PM
