Back button fires JavaScript onchange event

%3CLINGO-SUB%20id%3D%22lingo-sub-1101849%22%20slang%3D%22en-US%22%3ERe%3A%20Back%20button%20%22changes%22%20(mostly%20loses)%20form%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1101849%22%20slang%3D%22en-US%22%3EIsn't%20%22back%22%20button%20only%20supposed%20to%20take%20user%20back%20to%20the%20previous%20URL%3F%3CBR%20%2F%3Ethe%20contents%20of%20the%20URL%20can%20differ%2C%20the%20page%20might%20even%20need%20to%20be%20refreshed%20to%20work%20correctly%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1101988%22%20slang%3D%22en-US%22%3ERe%3A%20Back%20button%20%22changes%22%20(mostly%20loses)%20form%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1101988%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F310193%22%20target%3D%22_blank%22%3E%40HotCakeX%3C%2FA%3E%26nbsp%3B%20Never%20has%20been%20a%20problem%20before.%26nbsp%3BThese%20are%20values%20saved%20in%20a%20database%20and%20loaded%20on%20each%20page%20load.%20I%20can't%20even%20swear%20it's%20the%20back%20button%2C%20I%20just%20know%20that%20on%20subsequent%20loads%20of%20the%20page%2C%20the%20browser%20appears%20to%20be%20changing%20the%20values%20of%20these%20forms.%20FYI%2C%20I'm%20the%20developer%20for%20this%20site%2C%20so%20I%20can%20see%20that%20the%20values%20are%20being%20loaded%20correctly%20in%20PHP%2C%20this%20is%20a%20UI%20only%20issue.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1101565%22%20slang%3D%22en-US%22%3EBack%20button%20fires%20JavaScript%20onchange%20event%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1101565%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3ECurrently%20on%20Version%2081.0.387.0%20(Official%20build)%20canary%20(64-bit).%20Starting%20a%20few%20days%20(approx.%201%2F7%2F20)%2C%20a%20problem%20has%20developed%20with%20our%20Intranet%20site%20so%20that%20when%20we%20go%20back%3CSTRIKE%3E%2C%20forms%20are%20losing%20(and%20sometimes%20actually%20changing)%20values.%20Cannot%20consistently%20reproduce%2C%20but%20happens%205-10%20times%20a%20day.%20Usually%2C%20a%20refresh%20(F5)%20will%20restore%20the%20values%2C%20but%20not%20always%3C%2FSTRIKE%3E.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOk%2C%20now%20I%20know%20what%20is%20happening%20and%20yet%2C%20I%20have%20no%20idea%20why.%20When%20I%20click%20Back%20in%20Edge%2C%20and%20only%20Edge%20(I%20tested%20in%20Chrome%20and%20IE)%2C%20the%20onchange%20event%20of%20a%20specific%20element%20fires.%20I%20can%20reproduce%20this%20consistently.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F165675iB351F0F59146A458%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_1.png%22%20title%3D%22clipboard_image_1.png%22%20%2F%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1113231%22%20slang%3D%22en-US%22%3ERe%3A%20Back%20button%20%22changes%22%20(mostly%20loses)%20form%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1113231%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F310193%22%20target%3D%22_blank%22%3E%40HotCakeX%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20issue%20was%20not%20%22losing%20values%22%2C%20but%20somehow%20JavaScript%20events%20are%20firing%20that%20should%20have%20no%20possible%20way%20for%20that%20to%20occur.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1113242%22%20slang%3D%22en-US%22%3ERe%3A%20Back%20button%20%22changes%22%20(mostly%20loses)%20form%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1113242%22%20slang%3D%22en-US%22%3ESo%20no%20more%20a%20UI%20issue%3F%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1113280%22%20slang%3D%22en-US%22%3ERe%3A%20Back%20button%20%22changes%22%20(mostly%20loses)%20form%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1113280%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F310193%22%20target%3D%22_blank%22%3E%40HotCakeX%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWell%2C%20that%20was%20causing%20the%20UI%20issue%20-%20the%20JS%20being%20%22cached%22%20is%20an%20AJAX%20request%20that%20updates%20part%20of%20the%20page%20(and%20not%20doing%20it%20correctly%20since%20it%20should%20not%20be%20fired%20at%20that%20point).%20I%20could%20fix%20the%20AJAX%20issue%20to%20work%20anyway%2C%20but%20I%20need%20to%20know%20why%20it's%20even%20being%20called%20-%20makes%20no%20sense%2C%20but%20I%20can%20reproduce%20100%25%20of%20the%20time%20in%20Edge%2C%20but%20not%20in%20any%20other%20browser.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20fact%2C%20I%20just%20tested%20all%20the%20channels%20(latest%20version)%20-%20the%20issue%20does%20not%20occur%20in%20Beta%20or%20Stable%20but%20does%20occur%20in%20Dev%20and%20Canary.%20If%20this%20problem%20makes%20it%20to%20Beta%2C%20we%20will%20have%20big%20problems%20(we%20have%20users%20on%20Beta%20and%20Stable).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1113389%22%20slang%3D%22en-US%22%3ERe%3A%20Back%20button%20%22changes%22%20(mostly%20loses)%20form%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1113389%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F310193%22%20target%3D%22_blank%22%3E%40HotCakeX%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20added%20some%20debug%20code%20so%20that%20I%20could%20see%20all%20AJAX%20calls%20made%20and%20when%20I%20hit%20the%20back%20button%2C%20all%20of%20these%20are%20made%20that%20are%20on%20the%20page.%20All%20of%20which%20are%20tied%20to%20onchange%20or%20onclick%20events%20of%20specific%20elements.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1113402%22%20slang%3D%22en-US%22%3ERe%3A%20Back%20button%20%22changes%22%20(mostly%20loses)%20form%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1113402%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F50052%22%20target%3D%22_blank%22%3E%40Keith%20Davis%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22lia-spoiler-container%22%3E%3CA%20class%3D%22lia-spoiler-link%22%20href%3D%22%23%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%20target%3D%22_blank%22%3ESpoiler%3C%2FA%3E%3CNOSCRIPT%3E(Highlight%20to%20read)%3C%2FNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-border%22%3E%3CDIV%20class%3D%22lia-spoiler-content%22%3E%3CBLOCKQUOTE%3E%3CHR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F50052%22%20target%3D%22_blank%22%3E%40Keith%20Davis%3C%2FA%3E%26nbsp%3Bwrote%3A%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F310193%22%20target%3D%22_blank%22%3E%40HotCakeX%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWell%2C%20that%20was%20causing%20the%20UI%20issue%20-%20the%20JS%20being%20%22cached%22%20is%20an%20AJAX%20request%20that%20updates%20part%20of%20the%20page%20(and%20not%20doing%20it%20correctly%20since%20it%20should%20not%20be%20fired%20at%20that%20point).%20I%20could%20fix%20the%20AJAX%20issue%20to%20work%20anyway%2C%20but%20I%20need%20to%20know%20why%20it's%20even%20being%20called%20-%20makes%20no%20sense%2C%20but%20I%20can%20reproduce%20100%25%20of%20the%20time%20in%20Edge%2C%20but%20not%20in%20any%20other%20browser.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20fact%2C%20I%20just%20tested%20all%20the%20channels%20(latest%20version)%20-%20the%20issue%20does%20not%20occur%20in%20Beta%20or%20Stable%20but%20does%20occur%20in%20Dev%20and%20Canary.%20If%20this%20problem%20makes%20it%20to%20Beta%2C%20we%20will%20have%20big%20problems%20(we%20have%20users%20on%20Beta%20and%20Stable).%3C%2FP%3E%3CHR%20%2F%3E%3C%2FBLOCKQUOTE%3E%3C%2FDIV%3E%3CNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-noscript-container%22%3E%3CDIV%20class%3D%22lia-spoiler-noscript-content%22%3E%26nbsp%3Bwrote%3A%26nbsp%3B%26nbsp%3BWell%2C%20that%20was%20causing%20the%20UI%20issue%20-%20the%20JS%20being%20%22cached%22%20is%20an%20AJAX%20request%20that%20updates%20part%20of%20the%20page%20(and%20not%20doing%20it%20correctly%20since%20it%20should%20not%20be%20fired%20at%20that%20point).%20I%20could%20fix%20the%20AJAX%20issue%20to%20work%20anyway%2C%20but%20I%20need%20to%20know%20why%20it's%20even%20being%20called%20-%20makes%20no%20sense%2C%20but%20I%20can%20reproduce%20100%25%20of%20the%20time%20in%20Edge%2C%20but%20not%20in%20any%20other%20browser.%26nbsp%3BIn%20fact%2C%20I%20just%20tested%20all%20the%20channels%20(latest%20version)%20-%20the%20issue%20does%20not%20occur%20in%20Beta%20or%20Stable%20but%20does%20occur%20in%20Dev%20and%20Canary.%20If%20this%20problem%20makes%20it%20to%20Beta%2C%20we%20will%20have%20big%20problems%20(we%20have%20users%20on%20Beta%20and%20Stable).%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FNOSCRIPT%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3Eyou%20can%20have%20the%20fix%20ready%20beforehand%20so%20in%20case%20that%20happens%20you%20will%20be%20able%20to%20push%20it%20and%20prevent%20any%20issue%20in%20your%20organization%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1113407%22%20slang%3D%22en-US%22%3ERe%3A%20Back%20button%20%22changes%22%20(mostly%20loses)%20form%20values%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1113407%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F310193%22%20target%3D%22_blank%22%3E%40HotCakeX%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20don't%20know%20what%20you%20mean.%20There%20is%20no%20fix%20AFAIK.%20If%20a%20user%20hits%20the%20back%20button%2C%20JS%20events%20fire%20that%20should%20not%20unless%20the%20element%20is%20interacted%20with%20and%20I%20don't%20know%20of%20any%20way%20to%20work%20around%20the%20problem.%20This%20could%20be%20devastating%2C%20even%20cause%20data%20loss%20for%20us.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1117973%22%20slang%3D%22en-US%22%3ERe%3A%20Back%20button%20fires%20JavaScript%20onchange%20event%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1117973%22%20slang%3D%22en-US%22%3E%3CP%3EIssue%20is%20resolved%20in%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EVersion%2081.0.396.0%20(Official%20build)%20canary%20(64-bit)%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E(maybe%20before%2C%20but%20definitely%20in%20this%20build)%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Frequent Contributor

Currently on Version 81.0.387.0 (Official build) canary (64-bit). Starting a few days (approx. 1/7/20), a problem has developed with our Intranet site so that when we go back, forms are losing (and sometimes actually changing) values. Cannot consistently reproduce, but happens 5-10 times a day. Usually, a refresh (F5) will restore the values, but not always.

 

Ok, now I know what is happening and yet, I have no idea why. When I click Back in Edge, and only Edge (I tested in Chrome and IE), the onchange event of a specific element fires. I can reproduce this consistently.

 

clipboard_image_1.png 

 

 

 

 

 

9 Replies
Highlighted
Isn't "back" button only supposed to take user back to the previous URL?
the contents of the URL can differ, the page might even need to be refreshed to work correctly
Highlighted

@HotCakeX  Never has been a problem before. These are values saved in a database and loaded on each page load. I can't even swear it's the back button, I just know that on subsequent loads of the page, the browser appears to be changing the values of these forms. FYI, I'm the developer for this site, so I can see that the values are being loaded correctly in PHP, this is a UI only issue. 

Highlighted

@HotCakeX 

 

The issue was not "losing values", but somehow JavaScript events are firing that should have no possible way for that to occur.

Highlighted
So no more a UI issue?
Highlighted

@HotCakeX 

 

Well, that was causing the UI issue - the JS being "cached" is an AJAX request that updates part of the page (and not doing it correctly since it should not be fired at that point). I could fix the AJAX issue to work anyway, but I need to know why it's even being called - makes no sense, but I can reproduce 100% of the time in Edge, but not in any other browser.

 

In fact, I just tested all the channels (latest version) - the issue does not occur in Beta or Stable but does occur in Dev and Canary. If this problem makes it to Beta, we will have big problems (we have users on Beta and Stable).

Highlighted

@HotCakeX 

 

I added some debug code so that I could see all AJAX calls made and when I hit the back button, all of these are made that are on the page. All of which are tied to onchange or onclick events of specific elements.

Highlighted

@Keith Davis 

Spoiler

@Keith Davis wrote:

@HotCakeX 

 

Well, that was causing the UI issue - the JS being "cached" is an AJAX request that updates part of the page (and not doing it correctly since it should not be fired at that point). I could fix the AJAX issue to work anyway, but I need to know why it's even being called - makes no sense, but I can reproduce 100% of the time in Edge, but not in any other browser.

 

In fact, I just tested all the channels (latest version) - the issue does not occur in Beta or Stable but does occur in Dev and Canary. If this problem makes it to Beta, we will have big problems (we have users on Beta and Stable).


you can have the fix ready beforehand so in case that happens you will be able to push it and prevent any issue in your organization

 

@HotCakeX 

 

I don't know what you mean. There is no fix AFAIK. If a user hits the back button, JS events fire that should not unless the element is interacted with and I don't know of any way to work around the problem. This could be devastating, even cause data loss for us.

Highlighted

Issue is resolved in:

 

Version 81.0.396.0 (Official build) canary (64-bit)

 

(maybe before, but definitely in this build)