Featured post
xml - adding some jquery script to Magento page -
this has been driving me insane. can't figure out how append jquery script head section of particular page in magento 1.4.2. i've added latest jquery library pages editing page.xml, , i've added no conflict thing.
i know need add code custom layout update area page in question. nothing works, i've tried many pieces of code , none appear in head of page when later check source code.
i posted same question on official mangeto forum 8 days later , no replies. forum horrible getting advice questions unanswered :(. idea how add head via custom layout update example?
$(document).ready(function(){ $("a").click(function(event){ alert("thanks visiting!"); }); });
i've tried enclosing in script tags, in reference = head tag. nothing works. pulling hair out , i've googled every word phrase can think of no examples of how add scrip page's head in magento. please help.
expanding on alan's excellent summary. if want add file 1 specific page can use following snippet in layout update xml field:
<reference name="head"> <action method="addjs"><script>path/to/my/file.js</script></action> </reference>
and place file http://example.com/js/path/to/my/file.js
or if want residing in skin folder use
<reference name="head"> <action method="additem"><type>skin_js</type><name>js/file.js</name><params/></action> </reference>
with expected location http://example.com/skin/frontend/base/default/js/file.js change base , default according package , theme using
you can use above snippet in other layout/?.xml file place within layout handle want address. example place in cms pages in cms.xml you'll find
<cms_page> .... </cms_page>
and change to
<cms_page> ... <reference name="head"> <action method="addjs"><script>path/to/my/file.js</script></action> </reference> </cms_page>
and easy 1 adding snippet of javascript pages go system > configuration > design > footer > miscellaneous html
further reading:
- Get link
- X
- Other Apps
Comments
Post a Comment