Handbook
JavascriptFor security reasons, you cannot insert javascript directly into pages by simply cut and paste methods. Rather, BoltWire offers a couple secure work arounds.
Code JS
BoltWire has a special page in the default installation which allows you to set up your own one line javascript commands (set up as info vars). To use one of these in your page, simply call js=field in either a form or link.Here are some examples using some of the default javascript snippets. For a full list, take a look at code.js.
Use this to call up the print dialog (link or button)
[[{p}|PRINT|js=print]]
[button PRINT js=print]
[button PRINT js=print]
clear
Clears a form value on focus:
[text field 'Click here...' js=clear]
jump
Turns a select box into a page changer
[form]
[select jump js=jump]
[option '' 'Choose One']
[option {script}main Welcome]
[option {script}downloads Download]
[option {script}docs Documentation]
[option {script}extend Extensions]
[option {script}support Support]
[select]
[form]
[select jump js=jump]
[option '' 'Choose One']
[option {script}main Welcome]
[option {script}downloads Download]
[option {script}docs Documentation]
[option {script}extend Extensions]
[option {script}support Support]
[select]
[form]
[form]
[form]
[form]
alert
Here's how you send an alert. Notice how the parameter is sent through.
[[some.page|CLICK HERE|js='alert::Hello {id}!']]
back
Use js=back to return the user to the last page they viewed (equivalent to hitting the back button).
skip
Here's how to skip from one input to another. Click in box 1, then hit tab:
[form]
[text one js=skip::three]
[text two]
[text three]
[form]
[text one js=skip::three]
[text two]
[text three]
[form]
[form]
[form]
[form]
You can add as many of these short little js snippets as you like.
Note: You can also define a js snippet in config.php. To define js=clear above, I could have done the same thing with this line:
$BOLTformJs['clear'] = "onFocus=this.value=''";
This may be useful if you only want to define snippets for certain pages, or for certain plugins.
Embed
To insert a longer bit of javascript code, see the embed function. You can also combine these two approaches. Define a function in some code.embed page, and then add a line to code.js with some code to call that function.Because javascript is a significant security risk, you should always keep your code pages carefully protected.