how to get header in all the pages in visualforce page

JavaScript
<apex:page sidebar="false" showHeader="false" applyHtmlTag="false" 
    standardStylesheets="false" readonly="true"
    renderAs="pdf">
    <html>
        <head>
            <style type="text/css">
            @page {
                size: A5 landscape;
                @bottom-right {
                    content: "https://stackoverflow.com\A" counter(page) " of " counter(pages);
                white-space: pre-line;
                }
            }
            </style>
        </head>
    </html>
</apex:page>

Source

Also in JavaScript: