Loading...
 
Skip to main content

History: PluginJS

Source of version: 18

Copy to clipboard
            ! PluginJS
Use the JS ((wiki plugin)), introduced in ((Tiki3)), to include JavaScript files or JavaScript code in a wiki page. 

Alternatives: ((PluginHTML)) or ((PluginJQ))

!! Parameters
{pluginmanager plugin="js"}
!! Examples
!!! Basic syntax
{CODE(colors="tiki")}
Insert a javascript file or/and some javascript code.
{JS(file='file.js')}javascript code{JS}
{CODE}
The file.js file is in this case in the Tikiroot.

This will produce the following code for your Tiki site:
-+~lt~script type="text/javascript" src="file.js">~lt~/script>+-

Note that it has to be surrounded by quotes. 

{CODE(colors="tiki")}
{JS(file="http://example.org/tiki.js")}{JS}
{CODE}
{REMARKSBOX(title="Tip" type="tip")}Literal strings will have -+<+- , -+>+- , and -+&+- converted into HTML entities (and possibly other characters as well), so if your javascript is dealing with HTML (e.g. via -+document.write()+- ), you probably need to convert them back. 

!!! Example 1
To include JavaScript code, use:
{CODE(colors="tiki")}
{JS()}
 var....
 function ...
 ...
{JS}
{CODE}

This will produce the following code for your Tiki:
-+~lt~script type="text/javascript">+-
-+ var.... +-
-+ function ...+-
-+ ...+-
-+~lt~/script>+-

{REMARKSBOX(title="Tip" type="tip")}The file is inserted before the param, if you need the reverse order use 2 calls to the JS plugin.{REMARKSBOX}

!!! Example 2
''This code:''
{CODE(colors="tiki")}
{JS()}alert('coucou'){JS}
{CODE}

Would produce a pop up window that the user would have to click on "Accept" button ("D'accord" in this localized example) to make it disappear:
^::{img src="img/wiki_up/mod_js_cocou.png" }::^
!! Aliases
* (alias(Mod js))
        

History

Information Version
luciash d' being 🧙 19
Marc Laporte 18
Yves Kipondo 17
lindon 16
lindon 15
tjrob A note about the plugin converting text to HTML entities. 14
tjrob 13
Marc Laporte 12
Marc Laporte 10
lindon 9
Marc Laporte 8
Marc Laporte 7
Xavier de Pedro 6
sylvie 5
Rick Sapir / Tiki for Smarties 4
Xavier de Pedro 3
sylvie 2
system created from structure 1
Collapse/expand modules below