Title: Javascript in child functions.php
Last modified: August 30, 2016

---

# Javascript in child functions.php

 *  [ibogo](https://wordpress.org/support/users/ibogo/)
 * (@ibogo)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/javascript-in-child-functionsphp/)
 * We want a JavaScript function to apply to the entire homepage.
 * The code below works for the body, but not footer, header or sidebars.
 * Here it is:
 * `<div oncontextmenu="javascript:alert('Lorem Ipsum');return false;">`
 * Anyone know how to do this?
 * Thank you

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [ibogo](https://wordpress.org/support/users/ibogo/)
 * (@ibogo)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/javascript-in-child-functionsphp/#post-6534080)
 * Actually, not only homepage but sitewide.
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 8 months ago](https://wordpress.org/support/topic/javascript-in-child-functionsphp/#post-6534084)
 * Put the JS in a .js file in your Child Theme folder. Then enqueue that JS file:
   [https://codex.wordpress.org/Function_Reference/wp_enqueue_script](https://codex.wordpress.org/Function_Reference/wp_enqueue_script)
 * I don’t understand why you put the JS in a `<div>`
 *  Thread Starter [ibogo](https://wordpress.org/support/users/ibogo/)
 * (@ibogo)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/javascript-in-child-functionsphp/#post-6534183)
 * The <div> is wrapped around the entire homepage body.
 * On right-click, an alert pops up.
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 8 months ago](https://wordpress.org/support/topic/javascript-in-child-functionsphp/#post-6534185)
 * Do that in jQuery instead
    [http://stackoverflow.com/questions/1206203/how-to-distinguish-between-left-and-right-mouse-click-with-jquery](http://stackoverflow.com/questions/1206203/how-to-distinguish-between-left-and-right-mouse-click-with-jquery)
 *  Thread Starter [ibogo](https://wordpress.org/support/users/ibogo/)
 * (@ibogo)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/javascript-in-child-functionsphp/#post-6534195)
 * Have yet to use jQuery :s
 * Where would the code go?
 * **Update:** Nvm, found a good article. Will look into it. Thanks

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Javascript in child functions.php’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/customizr/4.4.24/screenshot.png)
 * Customizr
 * [Support Threads](https://wordpress.org/support/theme/customizr/)
 * [Active Topics](https://wordpress.org/support/theme/customizr/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/customizr/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/customizr/reviews/)

## Tags

 * [css](https://wordpress.org/support/topic-tag/css/)
 * [footer](https://wordpress.org/support/topic-tag/footer/)
 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [header](https://wordpress.org/support/topic-tag/header/)
 * [html](https://wordpress.org/support/topic-tag/html/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 5 replies
 * 2 participants
 * Last reply from: [ibogo](https://wordpress.org/support/users/ibogo/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/javascript-in-child-functionsphp/#post-6534195)
 * Status: not resolved