On the last page it won't be possible that easily, sorry. You can, however, place all necessary JavaScript at the top of the content. That is no problem with JS.
Another option is to introduce another (new) page before the last page and use buttonHide() there. This will then work very similary to the last page.