title: Run script after click on the link
body: <p>I will summarize my question in a simple example , i start</p>
  
  <p>I have two example pages when I make the demonstration </p>
  
  <p><strong>01.html</strong></p>
  
  <pre><code>   &lt;script&gt; 
      var demo = 'X1'
      alert(demo);
      $( document ).ready(function() {
      $("#cont").on("click","a", function ( e ) {
      history.pushState({}, '', $(this).attr("href"));
      $('body').load(this.href + " #bodyframe", function(){
      });
      event.preventDefault();
      }); 
      }); 
   &lt;/script&gt;
      &lt;body&gt;
      &lt;div id="bodyframe"&gt;
      page01&lt;br&gt;&lt;br&gt;
      &lt;div id="cont"&gt;&lt;a href="02.html"&gt;next page&lt;/a&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p><strong>page 02</strong></p>
  
  <pre><code>&lt;script&gt;
  var demo = 'X2'
  alert(demo)
  &lt;/script&gt;
  &lt;body&gt;
  &lt;div id="bodyframe"&gt;
  page02
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>When I run the page 01, it shows the alert with the variable 'demo' value, but when I click on the link and the page two is loaded, the page two don't show me the alert.
  In summarize, I need to run the script of the page 02 when I clicked the link and loaded the page since the function on click.</p>