جاري التحميل...

Geolocation HTML

Geolocation بإذن المستخدم عبر JS.

إجابة مباشرة

getCurrentPosition. لا وسم HTML.

Ask for position (requires permission)

html
HTML Code
<button id="loc" type="button">Share location</button>
<pre id="out"></pre>
<script>
document.getElementById("loc").onclick = function () {
if (!navigator.geolocation) {
document.getElementById("out").textContent = "No geolocation support";
return;
}
navigator.geolocation.getCurrentPosition(function (pos) {
document.getElementById("out").textContent =
pos.coords.latitude + ", " + pos.coords.longitude;
}, function () {
document.getElementById("out").textContent = "Permission denied or unavailable";
});
};
</script>

جرّب بنفسك

  1. http serve
  2. allow/deny
  3. UI both
  4. غرض واضح

أخطاء شائعة

  • on load
  • ignore deny

ملخص

  • permission
  • UI HTML
  • deny ok
  • privacy

🧠 اختبر معرفتك

جاهز للبدء

اختبر معرفتك

تحدى نفسك مع هذا الاختبار التفاعلي واكتشف مدى فهمك للموضوع

❓
3
الأسئلة
🎯
70%
للنجاح
♾️
∞
الوقت
🔄
∞
المحاولات

📝 التعليمات

  • اقرأ كل سؤال بعناية
  • اختر أفضل إجابة لكل سؤال
  • يمكنك إعادة الاختبار عدة مرات كما تريد
  • سيتم عرض تقدمك في الأعلى