File tree Expand file tree Collapse file tree 4 files changed +29
-28
lines changed
AdminUI/LearningHub.Nhs.AdminUI
Views/Shared/Tenant/LearningHub Expand file tree Collapse file tree 4 files changed +29
-28
lines changed Original file line number Diff line number Diff line change 7878 </environment >
7979 @* <script type="text/javascript" src="~/js/bundle/header.js"></script>*@
8080 <partial name =" ~/Views/Shared/_ValidationScriptsPartial.cshtml" />
81+
8182 @RenderSection( "Scripts", required: false)
83+ <script type =" text/javascript" src =" ~/js/pageunload.js" asp-append-version =" true" ></script >
8284 <script type =" text/javascript" >
83- // This function will be called when the browser window is closed or unloaded
84- function tellServerBrowserClosed () {
85- // Send an asynchronous request to the server when the browser is closed
86- fetch (' /api/user/browser-close' , {
87- method: ' POST' ,
88- headers: {
89- ' Content-Type' : ' application/json'
90- },
91- body: JSON .stringify ({ message: ' Browser closed' })
92- })
93- .then (response => response .json ())
94- .catch (error => console .error (' Error sending data to server:' , error));
95- }
96-
9785 // Bind the function to the unload event
9886 window .onunload = tellServerBrowserClosed;
9987
Original file line number Diff line number Diff line change 1+ // This function will be called when the browser window is closed or unloaded
2+ function tellServerBrowserClosed ( ) {
3+ // Send an asynchronous request to the server when the browser is closed
4+ fetch ( '/api/user/browser-close' , {
5+ method : 'POST' ,
6+ headers : {
7+ 'Content-Type' : 'application/json'
8+ } ,
9+ body : JSON . stringify ( { message : 'Browser closed' } )
10+ } )
11+ . then ( response => response . json ( ) )
12+ . catch ( error => console . error ( 'Error sending data to server:' , error ) ) ;
13+ }
Original file line number Diff line number Diff line change 161161 @RenderSection( "Scripts", required: false)
162162
163163 <script type =" text/javascript" src =" ~/js/mkplayer-ui-custom.js" asp-append-version =" true" ></script >
164+ <script type =" text/javascript" src =" ~/js/pageunload.js" asp-append-version =" true" ></script >
164165
165166 <script type =" text/javascript" >
166- // This function will be called when the browser window is closed or unloaded
167- function tellServerBrowserClosed () {
168- // Send an asynchronous request to the server when the browser is closed
169- fetch (' /api/user/browser-close' , {
170- method: ' POST' ,
171- headers: {
172- ' Content-Type' : ' application/json'
173- },
174- body: JSON .stringify ({ message: ' Browser closed' })
175- })
176- .then (response => response .json ())
177- .catch (error => console .error (' Error sending data to server:' , error));
178- }
179-
180167 // Bind the function to the unload event
181168 window .onunload = tellServerBrowserClosed;
182169
Original file line number Diff line number Diff line change 1+ // This function will be called when the browser window is closed or unloaded
2+ function tellServerBrowserClosed ( ) {
3+ // Send an asynchronous request to the server when the browser is closed
4+ fetch ( '/api/user/browser-close' , {
5+ method : 'POST' ,
6+ headers : {
7+ 'Content-Type' : 'application/json'
8+ } ,
9+ body : JSON . stringify ( { message : 'Browser closed' } )
10+ } )
11+ . then ( response => response . json ( ) )
12+ . catch ( error => console . error ( 'Error sending data to server:' , error ) ) ;
13+ }
You can’t perform that action at this time.
0 commit comments