By using a switch statement without any breaks we make the building of the
pathway extremely versatile. It would be very easy for us to add an extra hierarchical
layer to the pathway based on this.
JavaScript
In order to add JavaScript cleanly it should be added to the document header. We
can use the following methods to add JavaScript in this way:
The addScript() method is used to add a link to an external JavaScript file.
This is an example of how to use the addScript() method:
$js = JURI::base().'components/com_foobar/assets/script.js';
$document->addScript($js);
The addScriptDeclaration() method is similar; it allows us to add
RAW JavaScript to the header. This is an example of how to use the
addScriptDeclaration() method:
$js = 'function notify(text) { alert(text); }';
$document->addScriptDeclaration($js);
We can use these two methods for any type of script. If we want to use script other
than JavaScript, we can supply a second parameter defining the script MIME type.
For example, if we wanted to use Visual Basic Script we would specify the MIME
type text/vbscript.
Pages:
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359