Question: Need to close all new window opened by my application

Question

Need to close all new window opened by my application

Answers 1
Added at 2017-01-05 09:01
Tags
Question

I have tried to close the new window by Window.close() this works for current tab close but I need to close all the new tabs opened by my application var newwindow=null; function NewWindow(mypage,myPagename) { params = 'width='+screen.width; params += ', height='+screen.height; params += ', top=0, left=0'; params +=', scrollbars=yes,menubar=yes,toolbar=yes'; newwindow=window.open(mypage,myPagename, params); if (window.focus) { newwindow.focus() } return false; }

Shall we close the new window by having their name , if yes means how ???

Answers
nr: #1 dodano: 2017-01-05 10:01

You can assign window.open() to a variable and then addEventListener to the window variable. Something like this:

var testWindow = window.open("enter/your/url"); testWindow.addEventListener('loadstart', yourListenerFunction);

Now when you want to close the window, you need to do this:

testWindow.removeEventListener('loadstart', yourListenerFunction); testWindow.close();

removeEventListener() method removes the event listener previously registered with addEventListener().

Source Show
◀ Wstecz