# How to Intercept page scroll event

**URL:** <https://meta.discourse.org/t/how-to-intercept-page-scroll-event/44069>\
**Category:** Development\
**Created:** [2016 年 5 月 11 日午後 6:15 UTC](https://meta.discourse.org/t/how-to-intercept-page-scroll-event/44069 "2016-05-11T18:15:03Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![itkin](https://avatars.discourse-cdn.com/v4/letter/i/22d042/32.png) [@itkin](https://meta.discourse.org/u/itkin)\
**Post date:** [2016 年 5 月 12 日午前 9:13 UTC](https://meta.discourse.org/t/how-to-intercept-page-scroll-event/44069/3 "2016-05-12T09:13:44Z")

</div>

Got it, for anyone in the same case you need to add the following script into the body (via the admin interface)

```
<script type="text/javascript">
    Discourse.initializer({
      name: 'custom-header',

      initialize: function(application) {
        
        application.registrations['app-events:main']
            .on('header:show-topic', function(e){ 
                $('#top-navbar').css('zIndex',0) 
            })
            .on('header:hide-topic', function(e){ 
                $('#top-navbar').css('zIndex',1001) 
            })
      }
   });
</script>

```

---

_[View the full topic](https://meta.discourse.org/t/how-to-intercept-page-scroll-event/44069)._
