콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2230 화면

Hi, I am developing a custom module to create several pages on a website. Does anyone know how to load a js file for each page? I ask that because If you load on web.assets.frontend 1 file this is executed every time you navigate on every page.

아바타
취소
베스트 답변

Hi,

One thing you could do is check window.location.href == 'the page url' and then write the functions required for the page, or if there’s a specific class to identify the page, you can find it using jQuery and then write the code inside that.

if($(‘identifier)) {
    function
}

Or you can add the script in the XML so that it only loads when the specific page loads.

Regards

아바타
취소
관련 게시물 답글 화면 활동
1
10월 18
3738
2
12월 22
6253
5
1월 22
11877
1
8월 16
5236
1
5월 25
8427