Title: Manually edit JS to set offset
Last modified: November 5, 2018

---

# Manually edit JS to set offset

 *  Resolved [webmix](https://wordpress.org/support/users/webmix/)
 * (@webmix)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/manually-edit-js-to-set-offset/)
 * Hi there,
 * I love your plugin, I use it in many projects.
    This time I bought a theme that
   is a real disaster, the worst code I’ve ever seen in WP (nobody is perfect..)
 * Offset on mobile is not working, but I’m pretty sure it’s a conflict with some
   other JS from that theme. (I checked “prevent other scripts…” but it’s not helping)
 * I was thinking I could just fix the mobile offset by coding it myself with JS,
   with a small piece of code: detect windows size, change the offset var in the
   case window < 600px
 * Is it any possible ?
 * thanks

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

 *  Plugin Author [malihu](https://wordpress.org/support/users/malihu/)
 * (@malihu)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/manually-edit-js-to-set-offset/#post-10849323)
 * Yes you could do this. Can you post your URL so I could check it? I might be 
   able to provide an exact solution if I could see your page 🙂
 *  Thread Starter [webmix](https://wordpress.org/support/users/webmix/)
 * (@webmix)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/manually-edit-js-to-set-offset/#post-10849369)
 * Hi Malihu,
 * Thanks for the fast answer.
    The URL is: [http://demo.webmix.fr/anabolic/](http://demo.webmix.fr/anabolic/)
 * thank you 😉
 *  Plugin Author [malihu](https://wordpress.org/support/users/malihu/)
 * (@malihu)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/manually-edit-js-to-set-offset/#post-10850983)
 * Hello again,
 * I checked your page. The issue you’re having on mobile comes from the mobile-
   menu plugin (not the theme itself).
 * The mobile-menu plugin has its own function for scrolling the page and this prevents“
   Page scroll to id” from doing its thing (like scrolling the page, applying the
   offset etc.)
 * The mobile-menu script that does this is:
 * `...wp-content/plugins/mobile-menu/includes/js/mobmenu.js`
 * The code in the js script above is written is such way that it cannot be “corrected”
   via the “Prevent other scripts…” option.
 * There are 2 ways to fix this. The 1st way is an actual solution. The 2nd way 
   is more of a hack. I’ll post both ways so choose the one you want 😉
 * **Solution 1**
 * This is an actual solution as it’ll allow you to use “Page scroll to id” with
   all its functions on the mobile menu (i.e. the same way it works on the desktop
   menu).
 * Edit the `...wp-content/plugins/mobile-menu/includes/js/mobmenu.js` script.
 * Find the line 165:
 * `.not('[href="#0"]')`
 * Enter a new line below it and copy/paste this:
 * `.not('._mPS2id-h')`
 * Save the file and test your page.
 * **Solution 2**
 * This is more of a hack in the sense that it’ll allow you to offset mobile scrolling
   via CSS but you’ll still use the mobile-menu function to scroll the page (i.e.
   some “Page scroll to id” options like offset won’t apply or have any effect on
   mobile).
 * You’ll need to add the following CSS rule to your target sections:
 *     ```
       @media (max-width: 991px){
           #about, #formules, #equipe, #planning, #contact{
               padding-top: 95px !important;
               margin-top: -95px !important;
           }
       }
       ```
   
 * The `!important` part might not be needed depending on the other CSS rules, so
   check it and remove it if it works well without it.
 * Save the styles and test your page.
 * That’s it.
 * The culprit on the 1st solution is that you’ll need to re-edit the `mobmenu.js`
   if/when you update the mobile-menu plugin to a new version.
 * Let me know if it worked and which solution you applied 🙂
 *  Thread Starter [webmix](https://wordpress.org/support/users/webmix/)
 * (@webmix)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/manually-edit-js-to-set-offset/#post-10851411)
 * Hi Malihu,
 * Thank you very much for such a detailed answer!
 * I used solution number 2, it is more pragmatic. It works like a charm !
    And 
   anyway, nowaday, I feel like customizing a WP theme is only doing hacks and hacks
   🙂
 *  Thread Starter [webmix](https://wordpress.org/support/users/webmix/)
 * (@webmix)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/manually-edit-js-to-set-offset/#post-10851414)
 * @ mod that will look here, sorry I clicked “report” but I didn’t think it would
   immediatly do a report, i’m just looking for a way to remove the link that I 
   posted here, it won’t be any helpful for the community later since it’s a temporary
   link that will be removed very soon.
    Sorry about that
    -  This reply was modified 7 years, 8 months ago by [webmix](https://wordpress.org/support/users/webmix/).
 *  Plugin Author [malihu](https://wordpress.org/support/users/malihu/)
 * (@malihu)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/manually-edit-js-to-set-offset/#post-10851514)
 * You’re welcome 🙂
 * I think I added the wrong breakpoint for your page in the media query. In the
   CSS just change:
 * `@media (max-width: 991px){`
 * to:
 * `@media (max-width: 780px){`
 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [7 years, 8 months ago](https://wordpress.org/support/topic/manually-edit-js-to-set-offset/#post-10852307)
 * > @ mod that will look here, sorry I clicked “report” but I didn’t think it would
   > immediatly do a report, i’m just looking for a way to remove the link that 
   > I posted here, it won’t be any helpful for the community later since it’s a
   > temporary link that will be removed very soon.
 * I’m sorry, but unless it’s an extreme case posts and replies are not edited.
 * [https://wordpress.org/support/guidelines/#deleting-editing-posts](https://wordpress.org/support/guidelines/#deleting-editing-posts)
 * Search engine hits are _never_ considered extreme and there is nothing sensitive
   here or on that link. Your reply will not be edited.
 *  Thread Starter [webmix](https://wordpress.org/support/users/webmix/)
 * (@webmix)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/manually-edit-js-to-set-offset/#post-10852467)
 * > I’m sorry, but unless it’s an extreme case posts and replies are not edited.
 * Yes, that’s what I read, no problem about it. My apologies for hitting the report
   button!
 * > You’re welcome 🙂
   > I think I added the wrong breakpoint for your page in the media query. In the
   > CSS just change:
   >     ```
   >     @media (max-width: 991px){
   > 
   >     to:
   > 
   >     @media (max-width: 780px){
   >     ```
   > 
 * Hi [@malihu](https://wordpress.org/support/users/malihu/), yep no problem i will
   adjust the media query 😉
    Thanks for the help!
    -  This reply was modified 7 years, 8 months ago by [webmix](https://wordpress.org/support/users/webmix/).
 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [7 years, 8 months ago](https://wordpress.org/support/topic/manually-edit-js-to-set-offset/#post-10852529)
 * > Yes, that’s what I read, no problem about it. My apologies for hitting the 
   > report button!
 * It’s all good and thanks for understanding. 😀

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

The topic ‘Manually edit JS to set offset’ is closed to new replies.

 * ![](https://ps.w.org/page-scroll-to-id/assets/icon-256x256.png?rev=1401043)
 * [Page scroll to id](https://wordpress.org/plugins/page-scroll-to-id/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/page-scroll-to-id/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/page-scroll-to-id/)
 * [Active Topics](https://wordpress.org/support/plugin/page-scroll-to-id/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/page-scroll-to-id/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/page-scroll-to-id/reviews/)

 * 9 replies
 * 3 participants
 * Last reply from: [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * Last activity: [7 years, 8 months ago](https://wordpress.org/support/topic/manually-edit-js-to-set-offset/#post-10852529)
 * Status: resolved