Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- var currentURL = window.location.href;
- if (currentURL.indexOf('access-fine-location=1') === -1) {
- if (currentURL.indexOf('?') !== -1) {
- currentURL += '&access-fine-location=1';
- } else {
- currentURL += '?access-fine-location=1';
- }
- window.history.replaceState({}, document.title, currentURL);
- window.location.reload();
- }
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(function (position) {
- var latitude = position.coords.latitude;
- var longitude = position.coords.longitude;
- $.ajax({
- type: "GET",
- url: "<?php echo base_url('akun/update_longlat/update_longlat');?>",
- data: { latitude: latitude, longitude: longitude },
- success: function(response) {
- // Tampilkan pesan sukses atau lakukan tindakan lain yang diperlukan
- console.log("Data berhasil diperbarui");
- },
- error: function(xhr, status, error) {
- console.error("Terjadi kesalahan: " + error);
- }
- });
- }, function (error) {
- var confirmReload = confirm("Tidak dapat membaca lokasi Anda. Izinkan akses lokasi terlebih dahulu untuk alasan keamanan. Muat Ulang halaman?");
- if (confirmReload) {
- location.reload();
- } else {
- window.location.href = "/";
- }
- });
- } else {
- alert("Browser tidak mendukung geolokasi");
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment