How can I trigger an javascript (or jquery) event when I go to other page?
For exemple:
- I'm at index.html
- At index.html, I clicked on contact.html link;
- When I go to contact.html page, I need to trigger an event
Thanks for for your attention
EDIT:
I will try to explain in other way:
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:
<select name='type' id='type_select'>
<option value='0'></option>
<option value='1'>Home</option>
<option value='2'>Work</option>
</select>
<input type="text" name="contact_name" id="contact_name_input">
On my Javascript I have:
// 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();
}
});
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.
I hope to have been more clearer
Thanks for your attention