Right now, I am using a window.open(link, "_self");
to open a page on the same tab. It is working on all the browsers instead of Safari. On safari it will open a new tab. Is there any way to force safari to open the link in a same tab.
Asked
Active
Viewed 1,392 times
0

4lexandreC
- 43
- 6

ehsan jamshidi
- 31
- 6
-
Try this: `window.open = function(url){ window.location.href = url;};` – sidverma Jun 23 '20 at 03:58
-
Is there a difference between `window.open(link, "_self");` and `location = link;`? – traktor Jun 23 '20 at 03:58
-
@traktor53 I also tried **location.href** and got the same result. Cannot open the page in a same tab on safari. – ehsan jamshidi Jun 23 '20 at 04:19
-
@sidverma Thanks, but it did not work. still it is opening a new tab on Safari but it is working on the other browsers – ehsan jamshidi Jun 23 '20 at 04:22
-
Do any of the answers to [Why isnt window.location.href= not forwarding to page using Safari?](https://stackoverflow.com/q/31223216/52171420) work for you? It may also be interesting to re-test with popup blocking turned off. – traktor Jun 23 '20 at 05:02
1 Answers
0
I have tested in my Safari browser it worked. Try this:
var newwindow;
function openWindowInSameTab(url)
{
newwindow=window.open(url,'_self');
if (window.focus) {newwindow.focus()}
}
Call function: openWindowInSameTab('https://stackoverflow.com/');

sidverma
- 1,159
- 12
- 24