Documentation

AddHeadScript

CMain::AddHeadScript(
      $src, 
      $additional=false
)

The method adds java-scripts in the site and component templates. The procedure of adding and merging java scripts corresponds to the procedure for API calls. Exception: when merging, first the core scripts are grouped, and then the template scripts and pages are printed. Non-static method.

Parameters

Parameter Description Available from version
srcpath to script from the site root
additional

Examples of use

If the link to the script must be added into the body of the headtag (scr - link to script):

<?$APPLICATION->AddHeadScript('scr');?>

To add additional files to the head, the following must be used:

<?
// for js-files
$APPLICATION->AddHeadScript('/bitrix/templates/.default/additional.js');

// for css-files
$APPLICATION->SetAdditionalCSS("/bitrix/templates/.default/additional.css");
?>


© «Bitrix24», 2001-2024
Up