# Получить ID темы при загрузке страницы просмотра темы

**URL:** <https://meta.discourse.org/t/get-topic-id-when-the-topic-show-page-loads/155620>\
**Category:** Development\
**Created:** [22.Июнь.2020 21:05:32 UTC](https://meta.discourse.org/t/get-topic-id-when-the-topic-show-page-loads/155620 "2020-06-22T21:05:32Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Bcat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bcat/32/163148_2.png) [@Bcat](https://meta.discourse.org/u/Bcat)\
**Post date:** [23.Июнь.2020 02:45:05 UTC](https://meta.discourse.org/t/get-topic-id-when-the-topic-show-page-loads/155620/4 "2020-06-23T02:45:05Z")

</div>

Попробуйте

```plaintext
api.onPageChange((url, title) => {
    var res = url.match(/\/t\/(.*?)\/(\w+)/);
    if (res && res[2] > 0) {
        console.log(res[2]);
    }
});

```

---

_[View the full topic](https://meta.discourse.org/t/get-topic-id-when-the-topic-show-page-loads/155620)._
