API:regClientScript

From MODx Wiki

Jump to: navigation, search
 API Function Definition: 
regClientScript
Versions 
> 0.9.2 ?
Return Values
Success: unknown
Fail: unknown
Data Type 
string
Object Hierarchy 
DocumentParser
string regClientScript(string $src);


Registers Client-side JavaScript - these scripts are loaded at the end of the page.

This function will create the tags to include the given javascript file, or will insert a block of javascript code, immediately before the final </body> tag of this page. Using this function will allow you to use the javascript for the document that needs it, rather than having the scripts in the template for all documents, whether they need it or not.

Examples

$src = "<script type='text/javascript'>
  runSlideShow('slides');
</script>";
$modx->regClientScript($src);


Related functions

API:regClientStartupScript

Personal tools