Add JS to All Pages

Categories: Magento - Tags:

Magento has various locations for its javascipt files and there are several ways to add them to your page.
In order to add js to all your pages use javascript inclusion instruction within <default> handle in your layout file.
Here are some examples:

The layout below will add js/mydir/myscript.js javascript to all pages.
<default>
<action method=”addJs”><script>mydir/myscript.js</script></action>
</default>

Similarly this will add js from skin/frontend/js_package/js_theme/js/myscript.js.
<default>
<action method=”addItem”><type>skin_js</type><name>js/jqzoom/jquery-1.3.1.min.js</name></action>
</default>

This will add js from lib/myjs.js to all pages as well.
<default>
<action method=”addItem”><type>js</type><name>lib/myjs.js</name><params/><if>lt IE 7</if></action>
</default>

denys
Profile - Website

Comments

No comments yet.

Write a comment

You must be logged in to write a comment.

« »