this is an age verification for homepage.

<script language="javascript">

var agePrompt=prompt("What is your age?");

if (agePrompt>=18) alert('Welcome!')
else {
alert('Sorry! Come back in a few years!')
document.location=" ";//link if not 18


how can i do this for spesial categories?

closed as too broad by Anna Völkl, Fabian Blechschmidt, benmarks Jul 28 '14 at 16:29

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1) Javascript is easily defeated. You will need to have server-side code that does this. 2) There is a lot of work involved in this - you can look for an extension or start development yourself and we can help you with smaller questions. – benmarks Jul 28 '14 at 16:29

One way to accomplish this would be to save the content to a javascript file (age-verification.js).

Then go to Admin -> Catalog -> Manage Categories -> {Select your category} -> Custo Design -> Custom Layout Update


<reference name="head">
     <action method="addItem">

See http://blog.liip.ch/archive/2013/10/24/adding-javascript-and-css-files-to-head-section-of-magento.html

Also note you should be doing this server side, using php and session


You could try to use the custom layout update field in the category's custom layout tab.

Enter the layout update to add your Javascript file for this specific category only.

<reference name="head">
    <action method="addJs"><script>your_js_file</script></action>
    <action method="addCss">

the js file is sought in the /js folder, the css file in the templates skin folder

Not the answer you're looking for? Browse other questions tagged or ask your own question.