Add code just after Post content

There are some global variables available (or not) to detect the current page number:

if ( empty ( $GLOBALS['multipage'] ) or $GLOBALS['numpages'] === $GLOBALS['page'] )
    echo '<a id="lastPageLink" href="#comment">comment</a>';

The best way to understand what they do is a look at the internals of wp_link_pages().

  • (bool) $GLOBALS['multipage'] is TRUE if there is more than one page.
  • (int) $GLOBALS['numpages'] is the amount of available pages.
  • (int) $GLOBALS['page'] is the number of the current page.

In JavaScript you can add an onclick handler like this now:

document.getElementById("lastPageLink").onclick = function() {
    window.location.hash="comment";
    document.getElementById('comment').focus();
    return false;
}

tech