Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript window.navigator.standalone broken

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.

like image 910
owenmelbz Avatar asked May 17 '12 16:05

owenmelbz


People also ask

What is navigator standalone?

Navigator.standalone. Returns a boolean indicating whether the browser is running in standalone mode. Available on Apple's iOS Safari only.

What is JavaScript navigator?

The JavaScript navigator object is used for browser detection. It can be used to get browser information such as appName, appCodeName, userAgent etc. The navigator object is the window property, so it can be accessed by: window. navigator.

What is navigator used for in Windows?

The navigator object contains information about the browser. The location object is a property of the window object.


1 Answers

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.

like image 191
jjpcondor Avatar answered Oct 07 '22 00:10

jjpcondor