iPhone Mobile Safari scheint element.getBoundingClientRect zu fehlen. Was ist die entsprechende Methode auf iPhone Mobile Safari? Diese Methode existiert auf dem iPad.Was entspricht GetBoundingClientRect auf iPhone Mobile Safari 3?
Antwort
Edit 1: Dieser Code (webkitConvertPointFromNodeToPage) wird nur für sehr alte und veraltete Telefone benötigt ... siehe these comments.
EDIT 2: Ich würde nicht empfehlen, diesen Code zu verwenden ... Ich erinnere mich, es zu ändern, um mit einem Problem mit IE10 mit Touch-Zoom umzugehen. Ich werde versuchen, mich daran zu erinnern, den Code mit dem Update zu aktualisieren.
War: Ich denke, die folgenden Werke auf IE6 +, FF3 +, Safari 2+ (Desktop-& Mobile), Chrome (Desktop-& Android), Opera:
function offset(el) {
var convertPoint = window.webkitConvertPointFromNodeToPage;
if ('getBoundingClientRect' in el) {
var
boundingRect = el.getBoundingClientRect(),
body = document.body || document.getElementsByTagName("body")[0],
clientTop = document.documentElement.clientTop || body.clientTop || 0,
clientLeft = document.documentElement.clientLeft || body.clientLeft || 0,
scrollTop = (window.pageYOffset || document.documentElement.scrollTop || body.scrollTop),
scrollLeft = (window.pageXOffset || document.documentElement.scrollLeft || body.scrollLeft);
return {
top: boundingRect.top + scrollTop - clientTop,
left: boundingRect.left + scrollLeft - clientLeft
}
} else if (convertPoint) {
var
zeroPoint = new WebKitPoint(0, 0),
point = convertPoint(el, zeroPoint),
scale = convertPoint(document.getElementById('scalingEl'), zeroPoint);
return {
top: Math.round(point.y * -200/scale.y),
left: Math.round(point.x * -200/scale.x)
}
}
}
, wo die folgenden ein Kind des Körpers :
<div id="scalingEl" style="position:absolute;top:-200px;left:-200px;visibility:hidden;"></div>
Methode benötigt einige Fehlerprüfung (z. B. Element muss im Dokument sein). Scale funktioniert, wenn die Seite gezoomt wurde, ist aber möglicherweise nicht erforderlich (ich brauchte es, um webkitConvertPointFromNodeToPage in Windows Safari zu testen).
Für alle, die für die ele.getBoundingClientRect(). Breite Methode auf iOS 3, können Sie ele.offsetWidth verwenden
if("getBoundingClientRect" in this.container) {
this.width = this.container.getBoundingClientRect().width ;
}else {
this.width = this.container.offsetWidth; //http://help.dottoro.com/ljvmcrrn.php
}
- 1. iPhone Mobile Safari: Sonderzeichen
- 2. Mobile Safari auf iPhone/iPod CSS-Hack
- 3. funktioniert Javascript auf iPhone Mobile Safari XPpath?
- 4. Können Sie von Mobile Safari auf die iPhone-Kamera zugreifen?
- 5. iOS 7 Zugriff auf die iPhone-Kamera von Mobile Safari?
- 6. iphone/ipod mobile safari bewirkt, dass Videoelement auf Rotation verschwindet
- 7. Entfernen von Textarea Inner Shadow auf Mobile Safari (iPhone)
- 8. Mobile Safari SVG Problem
- 9. automatisches Zoomen auf iPhone Safari
- 10. Rich Text Editor auf Mobile Safari
- 11. HTML5 Mobile Safari DatePicker - Initialwert
- 12. Mobile Safari Mega Pixelgrenze?
- 13. Scrollbare UINavigationBar ähnlich Mobile Safari
- 14. CSS Trick ein einfaches Layout zu Safari Mobile (iPhone)
- 15. Mobile Safari Zurück-Taste
- 16. Mobile Safari Push Benachrichtigungen
- 17. Aktuelle Position des Ansichtsfensters in Mobile (iPhone) Safari abrufen
- 18. CSS Hintergrund-Position funktioniert nicht in Mobile Safari (iPhone/iPad)
- 19. mobile Safari Bild hochladen & ihre Größe
- 20. iPhone Mobile Safari, Wie viele maximale parallele HTTP-Verbindungen?
- 21. iOS8 iPhone 5 Mobile Safari kann nicht von Desktop Safari 7.0.6 inspiziert werden. "No Inspectable Applications"
- 22. Probleme PDF in iFrame auf Mobile Safari
- 23. IFrame Höhe Probleme auf iOS (mobile Safari)
- 24. Modify div location auf Zoom Mobile Safari
- 25. Mobile Safari Multi wählt Bug
- 26. Textbox-Fokus in mobile Safari setzen
- 27. Mobile Safari SVG Rendering Probleme mit Raphaeljs
- 28. <input type = "submit"> Padding Fehler auf Safari mobile?
- 29. "Anmeldung mit LinkedIn" funktioniert nicht auf Mobile Safari
- 30. Bootstrap 3 Navbar-Header ist nicht tappable/resonrend auf Mobile
eine einfachere Überprüfung kann ‚if (div.getBoundingClientRect) sein {} else {} " –