F
F
Franco Mannino2017-02-04 23:01:04
1C-Bitrix
Franco Mannino, 2017-02-04 23:01:04

How to insert js into templte.php of Bitrix?

How to insert a link is clear:

$APPLICATION->AddHeadScript('jquery.js');
$APPLICATION->AddHeadScript('javascript.js');

And how to insert such a script, as highlighted in the picture:
7db50ef1ff364835a192b701e8846150.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Gritsuk, 2017-02-04
@garinov

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>
');

R
Roman Yamchuk, 2017-02-14
@tomgif

//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 question

Ask a Question

731 491 924 answers to any question