Expandir minha barra de realizações na Comunidade.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

Esta conversa foi bloqueada devido à inatividade. Crie uma nova publicação.

SOLUCIONADO

MCM Component Click_Through_Link through error "Uncaught TypeError: Cannot read property 'getElementsByTagName' of null".

Avatar

Ex-membro da Comunidade

When I drag and drop the component Click_Through_Link of group  Call To Action on the page and refresh , I can see error in the console "Uncaught TypeError: Cannot read property 'getElementsByTagName' of null".

Why this is happening, please help .

1 Solução aceita

Avatar

Resposta correta de
Ex-membro da Comunidade

I got the problem.  Its is happening because of the way divID is created in the OOB component.

See /libs/mcm/components/cta-clickthroughlink/cta-clickthroughlink.jsp #line 72 

Id is encoded and used is html [divId = xssAPI.encodeForHTMLAttr(divId);]

And the same string divID is encoded in javascript (Written in /libs/mcm/components/cta-clickthroughlink/tracking-js.jsp #line21 ) to find the element which is wrong.

Solution : 

Override the component and replace below code in cta-clickthroughlink.jsp #line 72 

 divId = xssAPI.encodeForHTMLAttr(divId);
            %>
        <div id="<%=divId%>">

 

With

String divHTMLId =xssAPI.encodeForHTMLAttr(divId);

            %>
        <div id="<%=divHTMLId %>">

Ver solução na publicação original

4 Respostas

Avatar

Level 10

How are you setting the component in its dialog. Are you setting valid values: 

Make sure that you enter a valid URL. See this AEM doc for more information:

https://docs.adobe.com/docs/en/cq/5-6-1/wcm/campaigns/landingpages/extending-and-configuring-the-des...

Avatar

Ex-membro da Comunidade

Thank you for your response.

I am facing the same problem attached is the screen for my dialog.

Avatar

Level 9

@Aditi,

It seems there are some actions (On insert, edit etc) at the component level and those actions has some javascript functions which are failing. It seems the object which calls "getElementsByTagName" this method is undefined.

Check the listeners at the component level. Also, verify javascript in the component jsp.

Jitendra

Avatar

Resposta correta de
Ex-membro da Comunidade

I got the problem.  Its is happening because of the way divID is created in the OOB component.

See /libs/mcm/components/cta-clickthroughlink/cta-clickthroughlink.jsp #line 72 

Id is encoded and used is html [divId = xssAPI.encodeForHTMLAttr(divId);]

And the same string divID is encoded in javascript (Written in /libs/mcm/components/cta-clickthroughlink/tracking-js.jsp #line21 ) to find the element which is wrong.

Solution : 

Override the component and replace below code in cta-clickthroughlink.jsp #line 72 

 divId = xssAPI.encodeForHTMLAttr(divId);
            %>
        <div id="<%=divId%>">

 

With

String divHTMLId =xssAPI.encodeForHTMLAttr(divId);

            %>
        <div id="<%=divHTMLId %>">