-1

i want to close the popup modal confirm alert but above code is not working. I also tried popupcsd.onbeforeunload and popupcsd.onUnload but not working

var popupcsd = window.open('www.example.com', 'CSD ', 'width=1000, height=800');

    
    var popupcsd =window.open('www.example.com', 'CSD ', 'width=1000, height=800');

    popupcsd.beforeunload = function(){
                    console.log('leaving page'); // Use 'Preserve Log' option in 
    Console
                    alert('alert');
                    return leavingPageText;
                }

am working this code in Angular JS

Tanveer Hussain
  • 111
  • 1
  • 2
  • 12

2 Answers2

0

Instead of beforeunload use onbeforeunload

popupcsd.onbeforeunload = function(){
    console.log('leaving page');                    
    alert('alert');
    return leavingPageText;
}

I tried and its working on my end

cdoshi
  • 2,772
  • 1
  • 13
  • 20
0

Callback name that you have used is wrong. It should be changed as below.

 popupcsd.onbeforeunload instead of popupcsd.beforeunload
Thushan
  • 1,220
  • 14
  • 14