<link rel="apple-touch-startup-image" href="ipad-landscape748x1024.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)" />
Image de 748 de large (portrait), avec le contenu tourné:!!
<link rel="apple-touch-startup-image" href="ipad-portrait768x1004.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)" />
<link rel="apple-touch-startup-image" href="iphone320x460.png" media="screen and (max-device-width: 320px)" /> Portrait seulement.
On peut savoir si on est en mode application par la variable: if (navigator.standalone)
initial-scale=1 est nécessaire pour un bon affichage en mode paysage.
En CSS on peut utiliser les unités suivantes:
Le Zoom peut aussi être contrôlé via minimum-scale et maximum-scale dans le meta tag viewport.
var metaTagViewport = document.getElementsByName('viewport')[0];
if (metaTagViewport !=null)
metaTagViewport.setAttribute( 'content', 'device-width = '+viewport+', user-scalable=no');
La barre d'URL peut être masquée en forçant la page à scroller d'un cran dès l'affichage.
<body onload="window.scrollTo(0, 1)">
if (window.TouchEvent)
activerEvenementsTactiles();
<body ontouchmove="BlockMove(event);">
function BlockMove(event) {
// Ne pas déplacer la fenêtre!
event.preventDefault() ;
}
<body onorientationchange="myOrientationChangeFunction()">
En lisant window.orientation on a l'info sur l'orientation en cours (angle en degrés).
On peut empêcher la rotaion en utilisant CSS3: -webkit-transform: rotate(90);
if ('ondeviceorientation' in window) window.addEventListener('deviceorientation', function(event) {
console.log (Math.round(event.alpha) +'°');
}
Pour avoir l'accélération nette (sans la gravité) il faut un filtre (Highpass filter).
event.acceleration.z
if (window.DeviceMotionEvent) {
window.ondevicemotion = function(event) {
ax = event.accelerationIncludingGravity.x;
ay = event.accelerationIncludingGravity.y;
az = event.accelerationIncludingGravity.z;
}
}
Attention les y sont vers le haut de l'écran pour ce qui est de l'accélération contrairement aux ordonnées!
En complément:
Forum développeurs javascript pointu:
http://stackoverflow.com/questions/1273964/is-there-access-to-the-iphone-accelerometer-using-javascript
http://www.mobilexweb.com/blog/safari-ios-accelerometer-websockets-html5
https://developer.apple.com/../DeviceMotionEvent.html
(Highpass filter
)
<link media="only screen and (device-width: 480px)" href="iphone.css" type= "text/css" rel="stylesheet">
@media screen and (device-width: 480px) {
p { color: white; background-color: black; }
}
@media screen and (min-device-width: 481px) { p { color: black; background-color:white ; }}
@media screen and (max-device-width: 480px) { #logo_gd {width:80% }}
Safari iPhone intercepte certains liens et transmet la query string à l'application concernée. Voir aussi les URI avancées et la doc développeur Apple