내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Javascript code not injected Form-based

Avatar

Level 2

 

 

Hello,

 

I am trying to do a A/B Test, it has to be form-based. Our web page is build on SPA.  I login, then go to the specific page I want to see my code and the problem is that our code is not being injected there. I put the setInterval, I did the Audience Refinements in a right way but I don´t know what is happening

 

This is part of my code: 

<script>
var checkExist_alternativa = setInterval(function() {
//Si existe el elemento, cancelamos el interval y ejecutamos el código necesario
if (jQuery("#contract").length >= 1) {
clearInterval(checkExist_alternativa);

var nuevo = document.getElementById('contract); //SELECT THE ID WHERE I WANT TO INJECT MY NEW CODE
var htmlAB = ' HTML CODE';
nuevo.insertAdjacentHTML('afterbegin', htmlAB); //NEW HTML
var cssAB = '<style>CSS CODE</style>';
nuevo.insertAdjacentHTML('afterbegin', cssAB); //NEW CSS
}
}, 100);

</script>

 

Anyone knows how to solve this?

 

Thank you for helping me!

 

주제

토픽은 커뮤니티 콘텐츠를 분류하여 관련성 있는 콘텐츠를 찾는 데 도움이 됩니다.

SPA
1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 3

Hello,
I can see some error in JS code. May be that's the reason it's not executing. The change is ID selector 'contract' is not closed with quotes. 
Please resolve the error and try. If you are still seeing that's not working check the campaign is loading in the page or not.

var nuevo = document.getElementById('contract')

Thanks,
Hariharan S

원본 게시물의 솔루션 보기

2 답변 개

Avatar

정확한 답변 작성자:
Level 3

Hello,
I can see some error in JS code. May be that's the reason it's not executing. The change is ID selector 'contract' is not closed with quotes. 
Please resolve the error and try. If you are still seeing that's not working check the campaign is loading in the page or not.

var nuevo = document.getElementById('contract')

Thanks,
Hariharan S

Avatar

Level 2
Thank you I´ll check