Answer the question
In order to leave comments, you need to log in
How to insert js into templte.php of Bitrix?
How to insert a link is clear:
$APPLICATION->AddHeadScript('jquery.js');
$APPLICATION->AddHeadScript('javascript.js');
Answer the question
In order to leave comments, you need to log in
If template.php is a component template, then create a script.js file in the same folder next to template.php, and drop the script into it. It will be automatically loaded when the component is connected. You can read about component templates here.
If by template.php you mean the site template: header.php or footer.php, then you can use
$APPLICATION->AddHeadString('
<script>
//some script
</script>
');
//template.php
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
...
?>
<script>
//some script
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question