Loading...
 
Skip to main content

History: PluginJS

Source of version: 15

Copy to clipboard
            ! PluginJS
Use the JS ((wiki plugin)), introduced in ((Tiki3)), to include Javascript files or Javascript code in a wiki page. You can also use ((PluginHTML)) to embed Javascript in a page.
{maketoc}
!!Parameters
{pluginmanager plugin="js"}
!!Examples
!!! Basic syntax
{CODE(wrap=>1)}
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(wrap=>1)}
{JS(file="http://www.foo.com/tiki.js")}{JS}
{CODE}

__Note:__ 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()}
{JS()}
 var....
 function ...
 ...
{JS}
{CODE}

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

---

Note: the file is inserted before the param, if you need the reverse order use 2 calls to the JS plugins

!!!! Example 2
{CODE(wrap=>1)}
{JS()}alert('coucou'){JS}
{CODE}

Would produce a pop up window that the user would have to click on "Accept" button ("D'acord" in this localized example) to make it disappear.

^::{img src="img/wiki_up/mod_js_cocou.png" }::^

!!!! Note
Note: Some javescript are modified for security reasons. in 1.9 
For instance you need to use {CODE()}document.write('<form name="form" method="" action="" on');
document.write('Submit="return verif_champs( );">');{CODE} not to have onsubmit transformed.




-=alias=-
* (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