JDocument/addScript
From Joomla! Documentation
< JDocument(Difference between revisions)
m (Added table formatting.) |
m (Missed & in code sample.) |
||
| Line 23: | Line 23: | ||
To add a link to some JavaScript code at a specific URL, you could use: | To add a link to some JavaScript code at a specific URL, you could use: | ||
<source lang="php"> | <source lang="php"> | ||
| − | $doc = JFactory::getDocument(); | + | $doc =& JFactory::getDocument(); |
$doc->addScript( “http://www.example.com/js/myscript.js” ); | $doc->addScript( “http://www.example.com/js/myscript.js” ); | ||
</source> | </source> | ||
Revision as of 04:58, 8 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” );