Focus method from window object doesn't work in IE(2020) - javascript

MDN says that window.focus() is compatible with IE https://developer.mozilla.org/en-US/docs/Web/API/Window/focus.
But if I open IE and write
x=window.open('https://blank.org')
And after I come back to the main tab and I do x.focus() is not working.
I found several similar posts, but they are all old, and the information referred to there is out of date.
Is this happening by default, or is a IE setting?

I can reproduce the issue in IE 11. I searched docs and find that it might be due to some security issues the method can't be used in IE 8+. You can refer to this article:
Windows Internet Explorer 8 and later. The focus method no longer brings child windows (such as those created with the open method) to the foreground.
It can work in modern browsers because they have different engines than IE so the function can work.

Related

What is the browser support for element.removeAttribute?

The summary/details HTML5 element has terrible browser support. Therefore I built a non-jQuery fallback to make it work in non-supported browsers (IE and Edge). This fallback uses element.removeAttribute, but I am in doubt about the browser support of this command. I cannot find a definitive answer online. I have tried caniuse.com and MDN web docs, but they have no clear answers.
I know it works in my (updated) version of Firefox. Anyone has more info?
This method does not work consistently across browsers. It is BROKEN on MS Edge at least, and its brokenness is not mentioned by MDN, W3schools or caniuse at time of writing.
Basically, the method will fail when removing boolean attributes such as selected or hidden. The following will fail on Edge:
someDiv.removeAttribute("hidden");
Workaround is to set the attribute to "false" immediately before removing it.
someDiv.setAttribute("hidden", "false"); // "thanks" for the nonsense, MS
someDiv.removeAttribute("hidden");
This is not how boolean attributes are supposed to work, but that's how Edge requires it. Given that Edge is about to be dropped by Microsoft in favour of a Chromium-based alternative, we can expect this bug to remain unfixed, and the workaround to clutter our code for years.

IE javascript issue fixed by chanding document mode?

Im maintaining a site that I didn't build. It works fine in all browsers except IE where im running into an issue which is quite hard to debug.
I have a modal overlay that you click to close. In my IE 11 browser it wont close. When I have the document mode in the IE dev tools to Edge or 10 it works fine, but 9 (Default) and 8 both don't work.
I cant provide a link to my site or share the code here. I know this isn't very helpful for solving my issue, but what types of issues could be solved by changing the document mode? Could IE's quirks mode be to blame here?
I know this is quite an open ended question but presumably there are a limited amount of issues that apply to my situation?
could quirks mode be to blame?
If you're in compatibility mode (ie doc mode is 10, 9, 8 or 7) then by definition you're not in quirks mode (which is doc mode 5), so the short answer to that part of your question is No, it isn't quirks mode.
However, compatibility mode can cause itself cause issues. The whole point of compatibility mode is that the browser pretends to be an older version of itself. So in doc mode 8, you have IE11 pretending to be IE8.
That pretence isn't hugely accurate (so don't think that you're seeing your site the same as a real IE8 user would see it), but it does mean that IE11 will switch off various browser features in order to make itself work more like IE8.
Therefore, if your code is relying on a browser feature that was introduced after IE9, then that would indeed probably break your site in doc modes 9 and below. But without seeing any code, it is absolutely impossible for me to speculate any further about which particular aspect of your code would be causing this.
The only thing I can suggest is that you might get some clues by checking the console for error messages, but in reality if you want help, then you're going to need to need to swallow that "I can't share code" issue.

window.close() is not working in FF

We are using window.close() to close the current browser tab. It works for IE, Chrome, Safari, but not for FF.
We tried lot of solutions provided on Internet, but it seems they are not working.
window.open('','_parent','');
window.close();
Actually due to security reason and user experience aspects you can
now can't cause the browser to be closed[Completely], only popup
windows can be closed or the one parent to a script.
check the following mozilla support forum
possible duplicate of SO Question

Chrome touchenter touchleave

I've seen this question asked a couple times on here but no one has replied.
Before I go implementing the more resource intensive elementAtPoint method, can someone confirm that Chrome does not support touchenter and touchleave events?
The MDN documents it https://developer.mozilla.org/en-US/docs/Web/Reference/Events/touchenter
The latest W3C draft specifies it http://www.w3.org/TR/2011/WD-touch-events-20110505/
Does anyone know if any of the Chrome versions support it, even if it's in development, can I get it?
Well, pretty outdated I guess... Anyways, I've just used touch events, they are supported now, and Chrome will eventually emit touch events instead of clicking if you switch to device mode on the developer window (F12). Thus they are kinda easy to test.
CanIUse is also a friend: http://caniuse.com/#search=touch

onbeforeunload in Opera

I'm using the code that netadictos posted to the question here. All I want to do is to display a warning when a user is navigating away from or closing a window/tab.
The code that netadictos posted seems to work fine in IE7, FF 3.0.5, Safari 3.2.1, and Chrome but it doesn't work in Opera v9.63. Does anyone know of way of doing the same thing in Opera?
Thx, Trev
Opera does not support window.onbeforeunload at the moment. It will be supported in some future version, but has not been a sufficiently high priority to get implemented as of Opera 11.
onbeforeunload is now supported in Opera 15 based on the WebKit engine but not in any prior versions based on Presto.
Have you tried this?
history.navigationMode = 'compatible';
Reference, found via this page
I haven't actually tried it myself, but it looks promising.
Mobile Safari (iPhone/iPad) also doesn't support onbeforeunload, and I strongly suspect it is not likely to.
For detecting back/forward navigation there may be workarounds e.g. see Is there an alternative method to use onbeforeunload in mobile safari?.

Categories