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))