How to use
There are two test content modes - Text and Html. If you want to add HTML content, you need to switch to the Html mode.
When you paste a HTML content into the Html editor or load/import, the content runs through the HTML sanitizer, which removes head
, script
, style
, link
, and meta
elements and comments. It also removes attributes containing javascript:
or having name start with on
.
The values of href
, src
, srcset
attributes are replaced by #
(except iframe's src
attribute).
The sanitized content is added to a Html container by innerHTML
(i.e. it safe enough to paste a raw HTML page).
Note that the Html containers are Shadow DOMs and require special access (cannot be accessed by, e.g. document.querySelector
).
If you enable a Custom code editor, the program evaluates the whole internal code (see 'Internal code' which appears below the 'Results').
Otherwise, only the options that accept Object
, Array
or RegExp
are evaluated.
Tooltips can be called by pressing Ctrl/Cmd
key and cursor over an item.
The Ctrl/Cmd
key also can be used to prevent highlighting when switching mode in Html/Text editor.
In Html/Text editors undo/redo won't work (only while typing).
The performance is around two times slower than on the real browser page.
Using custom code
When the Custom code editor is activated, a minimal code with all callbacks is generated. For normal playground workflow, a two internal functions are necessary:
highlighter.flagStartElement()
in the each
callback for next/previous buttons functionality
highlighter.finish()
in the done
callback for highlighting matches and logging results
They're automatically added to the internal code if their parameters and functions parameters are the same.There are several function which can be used in custom code editor:
code.setHtml(text)
- dynamically sets HTML string in the HTML editor. See Iframes
example.
code.setText(text)
- dynamically sets text string in the Text editor
code.setListener(even, function)
- sets action on event in the search editor. See Mark while typing
example.
Warning: for the security reasons, do not import JSON from unknown origin without examination.
Saving tab state to the browser local storage isn't reliable. Save to file important tabs.