Expand my Community achievements bar.

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

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

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

Avatar

Former Community Member

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 Accepted Solution

Avatar

Correct answer by
Former Community Member

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 %>">

View solution in original post

4 Replies

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

Former Community Member

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

Correct answer by
Former Community Member

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 %>">