0
Answered

html block wont work with javascript

eveningpostdev 2 years ago in BLOX CMS updated by Joe Hansen (Product manager) 2 years ago 3

Hello, I am currently trying to add Javascript to change the html text of the block. For some reason the block does not want to accept/recognize the Javascript. Is there a reason for this? should a feature be turned on? Do I need to structure the Javascript in a unique way?

Answer

Answer
Answered

Hello, 

Yes, HTML blocks support javascript, no changes needed. anything like this will work. If you continue to have issues, please open a support ticket and one of our support engineers can look at what you are trying to do.

<h1 id='test'>Test</h1>

[script]

let testTarget = document.getElementById('test');

testTarget.innerHTML = "New Test";

[/script]

*note script tags changed so they can be shown in this editor.

Joe Hansen

Director of Solutions Support

Blox Digital

Answer
Answered

Hello, 

Yes, HTML blocks support javascript, no changes needed. anything like this will work. If you continue to have issues, please open a support ticket and one of our support engineers can look at what you are trying to do.

<h1 id='test'>Test</h1>

[script]

let testTarget = document.getElementById('test');

testTarget.innerHTML = "New Test";

[/script]

*note script tags changed so they can be shown in this editor.

Joe Hansen

Director of Solutions Support

Blox Digital

Then why does it not work here? I ran it on my a text editor and it works but not on Blox CMS.

Image 738

Please create a support ticket so we can address this specifically for your site.

Joe