JavaScript issue in IE when using the back button -


I have a form where users can inquire about two different areas. Form elements are shown by default for a field when the page is first loaded, while the form elements are hidden for field two. I have a select box where users can choose what the area is about to inquire about , And a bit of javascript to show and hide different parts depending on this area.

It works fine in Firefox and IE when the user clicks the browser back button in the user, often happens when users want to query a bit differently if the user inquired about the area two, Then pressed the back button in IE, the field selector still says "field two" but it is shown as elements of an area. I hope the field elements for the field two I still look like Firefox, but how?

The following is a brief example of my code:

  & lt; Script language = "javascript" type = "text / javascript" & gt; & Lt ;! - // Switch between fields function changeRegionType (form) {// we get different elements to manipulate var reg1 = getElementById ('region_1'); Var reg2 = getElementById ('region_2'); // hide one row, show others if ([[region_type ']. Value ==' region_1 ') {reg1.style.display =' '; Reg2.style.display = 'none'; } And if (if [[region_type ']. Value ==' region_2 ') {reg1.style.display =' none '; Reg2.style.display = ''; }} // -> & Lt; / Script & gt; & Lt; Form name = "queryform" action = "some.fp" method = "find" & gt; & Lt; Select name = "field_type" onChange = "changeRegionType (this.form)" & gt; & Lt; Option selected value = "area_1" & gt; Area One & lt; / Options & gt; & Lt; Option value = "region_2" & gt; Region Two & lt; / Options & gt; & Lt; / Select & gt; & Lt; Tr id = "region_1" & gt; & Lt ;! - Show this line to those people, which area 1 - & gt; & Lt; / TR & gt; & Lt; Tr id = "region_2" style = "display: none;" & Gt; & Lt ;! - Show this line to those people who want to ask about Area 2 - & gt; & Lt; / TR & gt; & Lt; / Form & gt;    

Remember the values ​​on the back / next orders of the form field page, So when you come back on the previous page, the last selected value 'field two' has been selected in the dropdown, but you will not get a onchange to do so.

As a result you should call the changeRegionType function to update the DOM from the selection on the Load event, iOSR, some browsers (Opera?) Actually Updates the form after download , so the function can pay for 0-timeout instead of fire in the onlin.

Due to Bfcache Firefox is not looking the same. This leaves the previous page when you leave it, is not displayed. When you go back to it, it can un-hide the current page DOM as it was never left. (This is done to increase the speed of back / forward navigations.) When a beefcase is disabled or your page exits due to the other pages it exits, then you will see the same behavior of IE and other browsers. (Safari 4 still has a similar BFsc facility.)


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -