i tired to find out way to close tab after log out in Firefox.
<script type='text/javascript'>
window.open('','_self');
window.close();
document.execCommand('ClearAuthenticationCache');
</script>
working in other browser but problem in Firefox. i need to close tab when signout/logout attempt.
Firefox will not allow you to close windows or tabs that a user opened.
Most financial sites for this reason will ask users to click a button and open a new window.
you can do this with window.open. Store the handle returned by that and use it to close the window you opened. The user may have many other tabs open in that window.
Refer: window.close
This is how you close a window that you open.
var openedWindow;
function openWindow()
{
openedWindow = window.open('moreinfo.htm');
}
function closeOpenedWindow()
{
openedWindow.close();
}
Related
I am trying to close Chrome/Safari browser tab using javascript. I tried all the below code. But nothing is working.
open('about:blank', '_self').close(); - This opens up a new tab, and the user is able to browse back. Which is not required.
open(location, '_self').close(); - Scripts may close only the windows that were opened by it.
window.open('','_parent','');
window.close(); - Not working
Is it a browser restriction?
The window.close doesn't work because it doesn't know what to close try this
//Global var to store a reference to the opened window
var openedWindow;
function openWindow() {
openedWindow = window.open('moreinfo.htm');
}
function closeOpenedWindow() {
openedWindow.close();
}
I have to close the current tab when clicking on a button. My current code is given below:
function isCloseWindow(){
window.opener = null;
window.open('', '_self', '');
window.close();
}
You can't close the current window from a script, only those, you have opened. There are some (mostly not working) hacks for this, but they are just that hacks.
I want to create a link that says 'Close' and it should close the window. Anyone have any idea how to do this?
I've looked at other people's questions and it seems I can't find anything that works.
This is what I have right now:
<a id="noThanks" href="JavaScript:window.close()">No, thanks</a>
There is javascript command for closing current window.
window.close();
or if you are opening named window
function openWin() {
myWindow = window.open("http://www.domain.com", "_blank", "width=200, height=100");
}
function closeWin() {
myWindow.close();
}
Using win.close() will close the window if win is a variable that has the value of a window.open() call stored in it.
So,
var win = window.open("//stackoverflow.com");
win.close();
will close the window opened by window.open().
However, window.close() only works on a window that was opened by JavaScript. That is, you can't close a window that a user navigated to by clicking a link.
To control a window, you'd have this:
Open Window
Then, in your new window, you'd have this to close it:
<button onclick="win.close();">Close</button>
You can only close a tab/window that you've opened using window.open
Similar question and answers can be found here
This is the answer I was really looking for in case anyone else ever needs it.
Just a heads up--this doesn't work in FF.
window.open('', '_self');
window.close();
In my case once data saved I need close window after confirmation .
<script type="text/javascript">
if (confirm("Close Window?"))
{
close();
}
</script>
Don't forgot to call jquery library before your script
So I'm having a popup that opens upon click on a link, but IE (8.0) doesnt want to show it.
Send page
And this function in JS:
function tellafriend(url) {
popup = window.open(url, "Send page", "width=500,height=600,scrollbars=yes,resizable=yes");
popup.focus();
}
IE tells me the error is at the line popup = window.open...
Any ideas on how to fix it?
I can't tell you why this happens, but IE doesn't let you have a space in the second parameter of window.open. If you change it to
popup = window.open(url, "Sendpage", "width=500,height=600,scrollbars=yes,resizable=yes");
the window will pop up.
I would like to have a button on a web page with the following behavior:
On the first click, open a pop-up.
On later clicks, if the pop-up is still open, just bring it to the front. If not, re-open.
The below code generally works in Firefox, Safari, and IE8 (see here for Chrome woes). However, I have found a failure mode in Firefox that I don't know how to deal with:
If for some reason the user has opened a second tab in the pop-up window and that second tab has focus within that window, the popupWindow.focus() command fails to have any effect. (If the first tab has focus within that window, everything works just great.)
So, how can I focus the popup and the desired tab in Firefox?
<head>
<script type="text/javascript">
var popupWindow = null;
var doPopup = function () {
if (popupWindow && !popupWindow.closed) {
popupWindow.focus();
} else {
popupWindow = window.open("http://google.com", "_blank",
"width=200,height=200");
}
};
</script>
</head>
<body>
<button onclick="doPopup(); return false">
create a pop-up
</button>
</body>