title: How to trigger a JavaScript event on a target page AFTER the user navigates to that page from another
body: <p>How can I trigger an javascript (or jquery) event when I go to other page?</p>
  
  <p>For exemple:</p>
  
  <ul>
  <li>I'm at index.html </li>
  <li>At index.html, I clicked on contact.html link;</li>
  <li>When I go to contact.html page, I need to trigger an event</li>
  </ul>
  
  <p>Thanks for for your attention</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I will try to explain in other way:</p>
  
  <p>I am working with RubyOnRails. I have a page where I can add contacts. There are a lot of fields but for this example I will use only two:</p>
  
  <pre><code>&lt;select name='type' id='type_select'&gt;
      &lt;option value='0'&gt;&lt;/option&gt;
      &lt;option value='1'&gt;Home&lt;/option&gt;
      &lt;option value='2'&gt;Work&lt;/option&gt;
  &lt;/select&gt;
  &lt;input type="text" name="contact_name" id="contact_name_input"&gt;
  </code></pre>
  
  <p>On my Javascript I have:</p>
  
  <pre><code>// this only works if I press CTRL+F5 to refreash the page
  $(document).ready(function(){
      $("#contact_name_input").hide();
  });
  // This Works fine
  $('#type_select').change(function(){
      if ($(this).val() == 1 || $(this).val() == 2){
          $("#contact_name_input").show();
      } else {
          $("#contact_name_input").hide();
      }
  });
  </code></pre>
  
  <p>In other words, what I need is to hide the input field when the user visit the page and to show it only if he selected a valid type.</p>
  
  <p>I hope to have been more clearer</p>
  
  <p>Thanks for your attention</p>