Warning: Undefined variable $filepath in /home/tiki-doc/public_html/lib/wiki-plugins/wikiplugin_tikidocfromcode.php on line 146
Include Javascript code or files | Documentation for Tiki Wiki CMS Groupware
Loading...
 
Skip to main content
Include Javascript code or files

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

Tiki Doc From Code error: js not found

Examples

Basic syntax

Copy to clipboard
Insert a javascript file or/and some javascript code. {JS(file='file.js')}javascript code{JS}

The file.js file is in this case in the Tikiroot.

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

Note that it has to be surrounded by quotes.

Copy to clipboard
{JS(file="http://example.org/tiki.js")}{JS}

{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:

Copy to clipboard
{JS()} var.... function ... ... {JS}


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

 Tip
The file is inserted before the param, if you need the reverse order use 2 calls to the JS plugin.

Example 2

This code:

Copy to clipboard
{JS()}alert('coucou'){JS}


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:

Image

Aliases


Created by system. Last Modification: Wednesday 27 July, 2022 23:43:47 GMT-0000 by Marc Laporte.
Show PHP error messages