Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working--what more is needed? #3

Open
szalapski opened this issue Nov 16, 2020 · 3 comments
Open

Not working--what more is needed? #3

szalapski opened this issue Nov 16, 2020 · 3 comments

Comments

@szalapski
Copy link

szalapski commented Nov 16, 2020

Hmm, it's not working for me. I added it in my client's Paogram.cs, and inject, just as the example. After I implement and attach a function to beforeUnload.BeforeUnloadHandler, shouldn't (in my browser console) window.beforeunload have a value? It does not for me.

@peterblazejewicz
Copy link
Owner

Hey,
yes, window.onbeforeunload, is usually used, but here event listener version is being used. When called from Blazor the event listener should be added, bound to C# handler via interop:
https://github.com/peterblazejewicz/blazor-beforeunload/blob/master/src/BlazorBeforeUnload/wwwroot/BeforeUnload.js
So technically, there should be window.BeforeUnloadInterop in your console if everything is OK (sorry, I haven't tested this wiht recent BL versions)

@tdashworth
Copy link

Hi, you need to add this to your wwwroot/index.html:

    <script src="_content/BlazorBeforeUnload/BeforeUnload.js"></script>

@nmt-ht
Copy link

nmt-ht commented Nov 18, 2022

yeah, I found this issue as well. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants