Make back button go to a different page
<p>I'd like to JavaScript, or JQuery (or any plug in actually) to force the browser to load a specific page when the back button is clicked. </p>

<p>Basically insert a page into the browser's history.</p>

<p>I've found a way of doing it below, but it seems long winded. Am I missing something?</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Back button test&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;script type="text/javascript"&gt;
         window.history.pushState('other.html', 'Other Page', 'other.html');
         window.history.pushState('initial.html', 'Initial Page', 'initial.html');
    &lt;/script&gt;

    Initial page &lt;br /&gt;

    &lt;script type="text/javascript"&gt;

         window.addEventListener("popstate", function(e) {
            if(document.URL.indexOf("other.html") &gt;= 0){
                document.location.href = document.location;
            }
         });

    &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
