Magento – How to add javascript to static block

blocksjavascriptmagento-1.9static-block

I have a javascript that I need to add to a static block. Could anyone explain it step by step?

Best Answer

Login to admin panel Click on CMS > Static Blocks.

Create New Block suppose Identifier = block_test

Add Content :

Click <a href="javascript:void(0)" onclick="checkFunction()">here</a> to check Javascript
<script type="text/javascript">// <![CDATA[
    function checkFunction(){
        alert('test Completed');
    }
// ]]></script>

For testing Create CMS page and call CMS block from CMS page

suppose URL Key = test

Add Content :

{{block type="cms/block" block_id="block_test"}}

Go to front end /test and click on "here" link, alert message will popup.

Related Topic