Actions

Difference between revisions of "JDocument/addScript"

From Joomla! Documentation

(New page: Adds the definition of a linked external script to the document object. Duplicates are ignored. ===Syntax=== void addScript( $url, $type ) where: {| !Argument !Data type !Description !De...)
 
m (Added table formatting.)
Line 4: Line 4:
  
 
where:
 
where:
{|
+
{| class="wikitable"
 
!Argument
 
!Argument
 
!Data type
 
!Data type

Revision as of 17:36, 7 September 2008

Adds the definition of a linked external script to the document object. Duplicates are ignored.

Syntax

void addScript( $url, $type )

where:

Argument Data type Description Default
$url string URL of script.
$type string MIME type of script. 'text/javascript'

Example

To add a link to some JavaScript code at a specific URL, you could use:

$doc = JFactory::getDocument();
$doc->addScript( “http://www.example.com/js/myscript.js” );

See also