API15

JHTML/script

From Joomla! Documentation

< API15:JHTML

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Write a <script></script> element

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

script($filename, $path= 'media/system/js/', $mootools=true)
Parameter Name Default Value Description
$filename The name of the script file *
$path 'media/system/js/' The relative or absolute path of the script file
$mootools true If true, the mootools library will be loaded

Defined in[edit]

libraries/joomla/html/html.php

Importing[edit]

jimport( 'joomla.html.html' );

Source Body[edit]

function script($filename, $path = 'media/system/js/', $mootools = true)
{
        // Include mootools framework
        if($mootools) {
                JHTML::_('behavior.mootools');
        }

        if(strpos($path, 'http') !== 0) {
                $path =  JURI::root(true).'/'.$path;
        };

        $document = &JFactory::getDocument();
        $document->addScript( $path.$filename );
        return;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

Code Examples[edit]