The code below gets the name of the current browser tab and closes it prior to opening a new tab. I use this for my menu navigation to close the current tab and open a new tab according to the user's navigation request.
closing the browser tab works fine for IE and Chrome but not for Firefox
According to your code and description, I create a sample, it seems that everything works well, I suggest you could use developer tools to debug your code, suppose it contains some javascript error.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
I use an alert to debug the value of objWindow as shown below. For IE and Chrome it displays [object Window] For Firefox the alert fails and just displays nothing. This proves my javascript is ok but Firefox is having an issue. There is some discussion
about popup settings and to try user_pref("dom.disable_open_click_delay", 0); but this did not help. I have default popup settings for all three browsers.
If still not working, I suppose the issue is related to the Firefox browser. Please check the browser setting, make sure it not disable JavaScript. Or, you could contact to the Firefox.
Best regards,
Dillion
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
This led me to figure out that if you open the next browser tab with the same name as the current browser tab, then you accomplish what my original question was - to close the current browser tab and open the next browser tab according to my page flow needs.
Member
246 Points
471 Posts
closing the browser tab works fine for IE and Chrome but not for Firefox
Jan 31, 2017 03:35 PM|gunderj|LINK
The code below gets the name of the current browser tab and closes it prior to opening a new tab. I use this for my menu navigation to close the current tab and open a new tab according to the user's navigation request.
var objWindow = window.open(location.href, "_self");
alert("objWindow: " + objWindow);
objWindow.close();
window.open(url, "_blank");
For Firefox only, the current tab does not close - the alert (debug) does not work either.
Can someone advise how to make this work in Firefox?
Thanks.
All-Star
45489 Points
7008 Posts
Microsoft
Re: closing the browser tab works fine for IE and Chrome but not for Firefox
Feb 01, 2017 05:54 AM|Zhi Lv - MSFT|LINK
Hi gunderj,
According to your code and description, I create a sample, it seems that everything works well, I suggest you could use developer tools to debug your code, suppose it contains some javascript error.
https://developer.mozilla.org/en-US/docs/Tools
Best regards,
Dillion
Member
246 Points
471 Posts
Re: closing the browser tab works fine for IE and Chrome but not for Firefox
Feb 02, 2017 02:50 PM|gunderj|LINK
Dillon,
I use an alert to debug the value of objWindow as shown below. For IE and Chrome it displays [object Window] For Firefox the alert fails and just displays nothing. This proves my javascript is ok but Firefox is having an issue. There is some discussion about popup settings and to try user_pref("dom.disable_open_click_delay", 0); but this did not help. I have default popup settings for all three browsers.
var objWindow = window.open(location.href, "_self");
alert("objWindow: " + objWindow);
//objWindow.close();
//window.open(url, "_blank");
Thanks for any feedback.
All-Star
45489 Points
7008 Posts
Microsoft
Re: closing the browser tab works fine for IE and Chrome but not for Firefox
Feb 08, 2017 02:11 AM|Zhi Lv - MSFT|LINK
Hi gunderj,
I suggest you could add a new page and test the following code in Firefox:
If still not working, I suppose the issue is related to the Firefox browser. Please check the browser setting, make sure it not disable JavaScript. Or, you could contact to the Firefox.
Best regards,
Dillion
Member
246 Points
471 Posts
Re: closing the browser tab works fine for IE and Chrome but not for Firefox
Feb 08, 2017 02:43 AM|gunderj|LINK
Thanks again Dillon,
This led me to figure out that if you open the next browser tab with the same name as the current browser tab, then you accomplish what my original question was - to close the current browser tab and open the next browser tab according to my page flow needs.