当前位置:   article > 正文

浏览器全屏相关常用代码_浏览器全屏代码

浏览器全屏代码
  1. /**
  2. * 浏览器判断是否全屏
  3. */
  4. export const fullscreenToggel = () => {
  5. if (fullscreenEnable()) {
  6. exitFullScreen();
  7. } else {
  8. reqFullScreen();
  9. }
  10. };
  11. /**
  12. * esc监听全屏
  13. */
  14. export const listenfullscreen = (callback) => {
  15. function listen () {
  16. callback()
  17. }
  18. document.addEventListener("fullscreenchange", function () {
  19. listen();
  20. });
  21. document.addEventListener("mozfullscreenchange", function () {
  22. listen();
  23. });
  24. document.addEventListener("webkitfullscreenchange", function () {
  25. listen();
  26. });
  27. document.addEventListener("msfullscreenchange", function () {
  28. listen();
  29. });
  30. };
  31. /**
  32. * 浏览器判断是否全屏
  33. */
  34. export const fullscreenEnable = () => {
  35. var isFullscreen = document.isFullScreen || document.mozIsFullScreen || document.webkitIsFullScreen
  36. return isFullscreen;
  37. }
  38. /**
  39. * 浏览器全屏
  40. */
  41. export const reqFullScreen = () => {
  42. if (document.documentElement.reques
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/283538
推荐阅读
相关标签
  

闽ICP备14008679号