The onBeforeUnLoad event does not fire after the PDF is loaded and displayed in iFrame.

%3CLINGO-SUB%20id%3D%22lingo-sub-1234902%22%20slang%3D%22en-US%22%3EThe%20onBeforeUnLoad%20event%20does%20not%20fire%20after%20the%20PDF%20is%20loaded%20and%20displayed%20in%20iFrame.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1234902%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%20our%20web%20application%20requires%20the%26nbsp%3B%3CEM%3Econfirm-to-leave%20dialog%3C%2FEM%3E%26nbsp%3Bwhen%20closing%20a%20browser%20window.%20We%E2%80%99ve%20registered%26nbsp%3B%3CEM%3EonBeforeUnLoad%20event%3C%2FEM%3E%26nbsp%3Bto%20our%20web%20page%20and%20it%20works%20fine.%20The%26nbsp%3B%3CEM%3Econfirm-to-leave%20dialog%3C%2FEM%3E%26nbsp%3Bwill%20be%20popped%20up%20when%20Click%20%E2%80%9CX%E2%80%9D%20icon%20to%20close%20the%20window%20(see%20image%20at%20step%203).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20after%20we%20load%20and%20display%20the%20PDF%20in%20iFrame%20then%20Click%20the%20%E2%80%9CX%E2%80%9D%20icon%20(see%20image%20at%20step%205)%2C%20the%20browser%20window%20will%20be%20closed%20without%20displaying%20the%26nbsp%3B%3CEM%3Econfirm-to-leave%20dialog%3C%2FEM%3E.%20This%20problem%20does%20not%20occur%20with%20IE11.%26nbsp%3B%20Please%20see%20our%20sample%20code%20in%20attached.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CU%3EQuestion%3C%2FU%3E%3C%2FSTRONG%3E%3CSTRONG%3E%3A%3C%2FSTRONG%3E%20How%20to%20display%20the%26nbsp%3B%3CEM%3Econfirm-to-leave%20dialog%3C%2FEM%3E%26nbsp%3Bafter%20loading%20PDF%20file%20to%20iFrame%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CU%3ESteps%20to%20simulate%20the%20issue%3C%2FU%3E%3C%2FSTRONG%3E%3CSTRONG%3E%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E1.%20Unzip%20the%20attached%3CSTRONG%3E%20onBeforeUnLoadIssue.zip%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E2.%20Run%20the%20MainPage.html%20in%20MS%20Edge%3C%2FP%3E%3CP%3E3.%20Click%20the%20%E2%80%9CX%E2%80%9D%20icon%2C%20the%26nbsp%3B%3CEM%3Econfirm-to-leave%20dialog%3C%2FEM%3E%26nbsp%3Bwill%20be%20popped%20up.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ChayankiatTI_0-1584523528117.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F177737i9268E81999BC445D%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22ChayankiatTI_0-1584523528117.png%22%20alt%3D%22ChayankiatTI_0-1584523528117.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E4.%20Click%20the%20%E2%80%9CStay%E2%80%9D%20button%E2%80%9D%20on%20the%26nbsp%3B%3CEM%3Econfirm-to-leave%20dialog%3C%2FEM%3E.%3C%2FP%3E%3CP%3E5.%20Click%20the%20%E2%80%9CMy%20PDF%E2%80%9D%20link%20to%20open%20the%20PDF%20file%20in%20iFrame%2C%20after%20the%20PDF%20file%20is%20loaded%20to%20iFrame%20then%20Click%20the%20%E2%80%9CX%E2%80%9D%20icon%20again.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ChayankiatTI_1-1584523528146.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F177738i36B1E9865A939662%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22ChayankiatTI_1-1584523528146.png%22%20alt%3D%22ChayankiatTI_1-1584523528146.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E6.The%20browser%20is%20closed%20without%20displaying%20the%20confirm-to-leave%20dialog.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EOur%20Environment%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CEM%3EWindows%2010%2C%201803%20(OS%20Build%2017134.1246)%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ChayankiatTI_2-1584523528153.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F177736i9F10DB87AA15C344%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22ChayankiatTI_2-1584523528153.png%22%20alt%3D%22ChayankiatTI_2-1584523528153.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CEM%3EMS%20Edge%2C%20Version%2042.17134.1098.0%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CEM%3EMS%20EdgeHTML%2017.17134%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ChayankiatTI_3-1584523528155.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F177739i1EC2169906857630%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22ChayankiatTI_3-1584523528155.png%22%20alt%3D%22ChayankiatTI_3-1584523528155.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1234902%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EonBeforeUnLoad%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1235415%22%20slang%3D%22en-US%22%3ERe%3A%20The%20onBeforeUnLoad%20event%20does%20not%20fire%20after%20the%20PDF%20is%20loaded%20and%20displayed%20in%20iFrame.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1235415%22%20slang%3D%22en-US%22%3EHi%2C%20welcome%20to%20the%20community!%3CBR%20%2F%3EI%20see%20you're%20using%20the%20legacy%20Edge%20which%20is%20discontinued.%20have%20you%20tried%20the%20new%20Edge%20browser%20which%20is%20based%20on%20Chromium%20engine%3F%3CBR%20%2F%3EYou%20can%20download%20the%20stable%2Frelease%20channel%20from%20here%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fedge%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fedge%2F%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eand%20insider%20channels%20from%20here%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.microsoftedgeinsider.com%2Fen-us%2Fdownload%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.microsoftedgeinsider.com%2Fen-us%2Fdownload%2F%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3Ethere%20is%20a%20high%20chance%20the%20problem%20doesn't%20exist%20in%20it.%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1237592%22%20slang%3D%22en-US%22%3ERe%3A%20The%20onBeforeUnLoad%20event%20does%20not%20fire%20after%20the%20PDF%20is%20loaded%20and%20displayed%20in%20iFrame.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1237592%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%20class%3D%22x_MsoNormal%22%3E%3CSPAN%3EThank%20you.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22x_MsoNormal%22%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22x_MsoNormal%22%3E%3CSPAN%3EPer%20you%20suggestion%2C%20our%20code%20works%20fine%20with%20the%20Chromium%20Engine%20base.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22x_MsoNormal%22%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22x_MsoNormal%22%3E%3CSPAN%3EAccording%20to%20our%20organization%20policy%2C%20we%20need%20to%20stay%20on%20this%20legacy%20Edge%20for%20another%20while.%20%26nbsp%3BDo%20you%20have%20any%20suggestion%20for%20a%20workaround%20while%20we%20need%20to%20stay%20on%20this%20legacy%20Edge%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22x_MsoNormal%22%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22x_MsoNormal%22%3E%3CSPAN%3ERegards%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22x_MsoNormal%22%3E%3CSPAN%3EChayankiatTI%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1237817%22%20slang%3D%22en-US%22%3ERe%3A%20The%20onBeforeUnLoad%20event%20does%20not%20fire%20after%20the%20PDF%20is%20loaded%20and%20displayed%20in%20iFrame.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1237817%22%20slang%3D%22en-US%22%3EI%20understand%2C%20no%20actually%20I%20don't%20but%20maybe%20someone%20else%20could%20help%20you%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1240433%22%20slang%3D%22en-US%22%3ERe%3A%20The%20onBeforeUnLoad%20event%20does%20not%20fire%20after%20the%20PDF%20is%20loaded%20and%20displayed%20in%20iFrame.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1240433%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F585257%22%20target%3D%22_blank%22%3E%40ChayankiatTI%3C%2FA%3E%26nbsp%3BThanks%20for%20reaching%20out!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'll%20ask%20one%20of%20our%20Devs%20and%20let%20you%20know%20if%20they%20have%20any%20insights.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CI%3EFawkes%20(they%2Fthem)Project%20%26amp%3B%20Community%20Manager%20-%20Microsoft%20Edge%3CI%3E%3C%2FI%3E%3C%2FI%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hello, our web application requires the confirm-to-leave dialog when closing a browser window. We’ve registered onBeforeUnLoad event to our web page and it works fine. The confirm-to-leave dialog will be popped up when Click “X” icon to close the window (see image at step 3).

 

However, after we load and display the PDF in iFrame then Click the “X” icon (see image at step 5), the browser window will be closed without displaying the confirm-to-leave dialog. This problem does not occur with IE11.  Please see our sample code in attached.

 

Question: How to display the confirm-to-leave dialog after loading PDF file to iFrame?

 

Steps to simulate the issue:

1. Unzip the attached onBeforeUnLoadIssue.zip

2. Run the MainPage.html in MS Edge

3. Click the “X” icon, the confirm-to-leave dialog will be popped up.

ChayankiatTI_0-1584523528117.png

4. Click the “Stay” button” on the confirm-to-leave dialog.

5. Click the “My PDF” link to open the PDF file in iFrame, after the PDF file is loaded to iFrame then Click the “X” icon again.

ChayankiatTI_1-1584523528146.png

6.The browser is closed without displaying the confirm-to-leave dialog.

 

Our Environment:

Windows 10, 1803 (OS Build 17134.1246)

ChayankiatTI_2-1584523528153.png

MS Edge, Version 42.17134.1098.0

MS EdgeHTML 17.17134

ChayankiatTI_3-1584523528155.png

Thank you.

4 Replies
Highlighted
Hi, welcome to the community!
I see you're using the legacy Edge which is discontinued. have you tried the new Edge browser which is based on Chromium engine?
You can download the stable/release channel from here:
https://www.microsoft.com/en-us/edge/

and insider channels from here:
https://www.microsoftedgeinsider.com/en-us/download/

there is a high chance the problem doesn't exist in it.
Highlighted

@HotCakeX 

Thank you. 

 

Per you suggestion, our code works fine with the Chromium Engine base. 

 

According to our organization policy, we need to stay on this legacy Edge for another while.  Do you have any suggestion for a workaround while we need to stay on this legacy Edge?

 

Regards,

ChayankiatTI

Highlighted
I understand, no actually I don't but maybe someone else could help you
Highlighted

@ChayankiatTI Thanks for reaching out!

 

I'll ask one of our Devs and let you know if they have any insights.

 

Fawkes (they/them)
Project & Community Manager - Microsoft Edge