Whether the js page is a screen display page

 

   reprint

 

//----------------------------Whether this page is displayed on the current screen
		function isShowing(){
			var hiddenProperty = 'hidden' in document ? 'hidden' :    
			    'webkitHidden' in document ? 'webkitHidden' :    
			    'mozHidden' in document ? 'mozHidden' :    
			    null;
			var visibilityChangeEvent = hiddenProperty.replace(/hidden/i, 'visibilitychange');
			var onVisibilityChange = function(){
			    if (!document[hiddenProperty]) {    
			        //console.log('On the current page');
					//document.title = 'Welcome back';			        
			    	});
			    }else{
			       // console.log('Not on the current page')
					//document.title = 'Why did you leave me';
			    }
			}
			document.addEventListener(visibilityChangeEvent, onVisibilityChange);
		}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326223005&siteId=291194637