Javascript window.navigator.standalone broken

2019-03-25 05:35发布

问题:

really annoying me now,

I've stripped my code down to this

$(function(){
  if ( ("standalone" in window.navigator) && !window.navigator.standalone ) {
    alert('full screen');
  }
});

yet every time I run this on my ipad FROM safari it kicks out the alert.

I've no idea why and its causing chaos to my whole uni project which is due monday! Any help would be amazing.

回答1:

When/if the web page is in standard/usual Safari mode, the "window.navigator.standalone" value will be False. Only when the web page is in "app mode/i.e. full screen mode", this value will be True. NOTE: this JavaScript value does not exist in browsers that do not support "app mode/i.e. full screen mode". So you should test both for the very existence of the property window.navigator.standalone as well as for its truthfulness.