Page Visibility APIã§ç¾å¨ã®WEBãã¼ã¸ãéãã¦ãããã©ãã
Javascriptã®Page Visibility APIã使ããã¨ã§ç¾å¨é²è¦§ãã¦ããWEBãã¼ã¸ã
éãã¦ãããã©ãã確èªãããã¨ãã§ããã
詳ãããã¨ã¯ä»¥ä¸ã®ãµã¤ãããåç
§
Page Visibility API の使用 - Web developer guide | MDN
å©ç¨ã·ã¼ã³ã¨ãã¦ã¯ï½¥ï½¥ï½¥
- ãã©ã¦ã¶ã®ã¿ãæ©è½ãå©ç¨ãã¦è¤æ°ã®åç»ãåçãçµæçã«ãµã¼ãã«è² è·ãæãããä»ã®å©ç¨è ã«è¿·æããã¦ãã¾ãã
- ç»åãé 次表示ãã¦ãããµã¤ãã§ãã¦ã¼ã¶ããã¼ã¸ãè¦ã¦ããªãã®ã«æ¬¡ã®ã¹ã©ã¤ãã¸é²ãã¹ãã§ã¯ãªããã®
- ãã©ã¦ã¶ã¡ã¼ã«ã§ãéãã¦ããæã«æ°åæ¯ã¡ã¼ã«ãµã¼ãã¸åãåãããè¡ããæ°ããã¡ã¼ã«ããã§ãã¯ãããã¨ã
- å©ç¨è ããè¦ããªããªã£ã¦ããï¼é¢ãã¦ããï¼é㯠ã²ã¼ã ãåæ¢ãã
ãªã©ï½¥ï½¥ï½¥è²ã 使ãããã§ããã
Page Visibility APIãå©ç¨ããã°ãWeb ãã¼ã¸ãè¦ãã¦ããªãã¨ãã«ä¸è¦ãªã¿ã¹ã¯ãå®è¡ããªãããã«ãããã¨ãã§ããçµæçã«ã¯ã©ã¤ã¢ã³ããã·ã³ã®CPUããããã¯ã¼ã¯ãªã©ã®ãã¼ãã¦ã§ã¢ãªã½ã¼ã¹ã®æ¶è²»ãæãããã¨ãã§ããã
ã¦ã¼ã¶ã¼ã®è¦ç¹ããã£ã¦WEBéçºãã¦ãããã¨ã¯ã©ã®æ代ã«ããã¦ãéè¦ã«ãªã£ã¦ããã¨æãã¾ãã
ãã ãPage Visibility APIã使ãããã©ã¦ã¶ã«ã¤ãã¦ã¯ã
IEã®å ´åã¯10以ä¸ãFirefoxãChromeã¯ã»ã¼å®è£
ã¨ãªã£ã¦ããã
ãã®è¾ºãçæãã¦ããå¿
è¦ããããã¨æãã¾ãã
対å¿ãã©ã¦ã¶ããã¼ã¸ã§ã³ã¯ä»¥ä¸ã®URLããã確èªãã¦ããã ãã¾ãã
Can I use... Support tables for HTML5, CSS3, etc
ç°¡åã§ããã¾ããã以ä¸ãJavascriptã®ãµã³ãã«ã§ãã
ã¦ã¼ã¶ã¼ãWEBãã¼ã¸ãè¦ã¦ããç¶æ
ã¯ã表示ãã¦ããã®ç§æ°ã«ã¦ã³ãã
å¥ã®ãã©ã¦ã¶ãä»ãã¼ã¸ï¼æå°åãå«ãï¼ãè¦ãã¨ãã¯ç§æ°ã«ã¦ã³ãã
ä¸æåæ¢ãããµã³ãã«ã§ãã
ãã®å¾ã¦ã¼ã¶ã¼ãæ»ã£ãã¨ãã«ç§æ°ã«ã¦ã³ããåéã§ãã¾ãã
var timer = 0; var PassSec = 0; $(document).ready(function(){ timer = setInterval(timeCount, 1000); if(document.addEventListener) { // ãã¼ã¸ã®è¡¨ç¤ºç¶æ ãå¤æ´ãããã¨ãã«å¸¸ã«çºçããã¤ãã³ãã document.addEventListener("visibilitychange",visibilitychangeShow); }; }); function visibilitychangeShow() { // ããã¥ã¡ã³ãã®å¯è¦æ§ã表ãå¤ãåå¾ãã // [visible]ãã¼ã¸ã®ã³ã³ãã³ãã¯å°ãªãã¨ãé¨åçã«å¯è¦ç¶æ // [hidden] ãã¼ã¸ã®ã³ã³ãã³ãã¯ã¦ã¼ã¶ããè¦ãã¦ããªãç¶æ visibilitySet = document.visibilityState; if (visibilitySet == "visible") { timer = setInterval(timeCount, 1000); } else { clearTimeout(timer); } } function timeCount() { PassSec++; var msg = "表示ãã¦ãã" + PassSec + "ç§ãçµé"; document.title = msg }
å®éã®åä½ã¯ä»¥ä¸ã®URLããã確èªãã¦ããã ãã¾ãã
http://owen11.web.fc2.com/visibility.html