cancel
Showing results for 
Search instead for 
Did you mean: 

How to add an external Javascript to a CMS Site or Static Block

How to add an external Javascript to a CMS Site or Static Block

Hi all,

 

I got an external Javascript which is working find outside of Magento. But if I want to insert that script into a CMS Site of Magento 1.9.x there is nothing displayed. Tried a lot of different things I already found on the net with the "Layout Update XML" but nothing works.

 

Does anyone maybe got a hint how to get that thing running?

 

The Script is like the follow:

 

<script>
  !function(e,t,a,r,X){var n,c=t.getElementsByTagName(a)[0];t.getElementById(r)||((n=t.createElement(a)).id=r,n.src="https://external-site/index.js",c.parentNode.insertBefore(n,c),e.xyCalculatorInit={selector:".xy-calculator",accessId:"cf91012d5257c9036c90eafcf36186c872642146d57135462ef64e50009ac6fa"},e.xyCalculator&&xyCalculator(e.xyCalculatorInit))}(window,document,"script","xy-calculator-script");
</script>
<div class="xy-calculator"></div>

thanks

Ben

3 REPLIES 3

Re: How to add an external Javascript to a CMS Site or Static Block

Put the script in a static block and call the block in a cms page

Re: How to add an external Javascript to a CMS Site or Static Block

Thank you for your answer. But I already tried that.

If I add some test-text and below the script, it shows only the text.

Re: How to add an external Javascript to a CMS Site or Static Block

@Benjamin9 yes you are right, when you add the script tag or any style tag there it only shows the text but that value is saved in database and you can check the value on the frontend.

 

Thanks