But in fact, each browser has different restrictions on this kind of behavior. Just imagine that you open a page and the page is directly made into full screen. That is very sad. Similarly restricted, there are also windows .open, continuous pop-up alerts, etc. This is the page permission.
There are also browser permissions. If you are developing a chrome extension, you should not be restricted
Additional point: Different similar trigger situations may have different results. Self-execution will have more restrictions, such as document.body.onload = function() { video.play() }; Playing a video directly as soon as you enter the page is very frustrating. Some browsers restrict this type of behavior and can only use triggering: document.body.onclick = function() {
You can refer here to learn more: http://javascript.ruanyifeng....
However, for operations such as changing the browser size, position, and full screen, the browser believes that this should be decided by the user rather than the website developer, so this type of code is blocked by default. A similar prompt will appear:
Theoretically, js supports
But in fact, each browser has different restrictions on this kind of behavior. Just imagine that you open a page and the page is directly made into full screen. That is very sad.
Similarly restricted, there are also windows .open, continuous pop-up alerts, etc.
This is the page permission.
There are also browser permissions. If you are developing a chrome extension, you should not be restricted
Additional point: Different similar trigger situations may have different results. Self-execution will have more restrictions, such as
document.body.onload = function() {
video.play()
};
Playing a video directly as soon as you enter the page is very frustrating. Some browsers restrict this type of behavior and can only use triggering:
document.body.onclick = function() {
};
You can refer here to learn more: http://javascript.ruanyifeng....
However, for operations such as changing the browser size, position, and full screen, the browser believes that this should be decided by the user rather than the website developer, so this type of code is blocked by default.
A similar prompt will appear: