edmon Posted September 6 Share Posted September 6 I am trying to create simple web that user can send their location via SMS using geolocation . The problem is I couldn't put link to SMS body. How can I put link on it? Any suggestion please, here is my code: <html> <head> <title>Please SEND your location</title> <script> if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (position) { const geoLocation = { latitude: position.coords.latitude, longitude: position.coords.longitude, }; console.log('Their location --->', geoLocation); }); } </script> <p> <a href="sms:+123456789?&body=https://www.google.com/maps/search/?api=1&query=${geoLocation.latitude},${geoLocation.longitude}">Sending a location</a> </p </html> Quote Link to comment https://forums.phpfreaks.com/topic/323896-how-to-put-custom-body-on/ Share on other sites More sharing options...
requinix Posted September 6 Share Posted September 6 You have code that is able to get their location. You need to take that location data and put it into the link at that time - you can't put it in there ahead of time. Take a look at MDN's geolocation examples for something that's actually very close to what you want to do. Quote Link to comment https://forums.phpfreaks.com/topic/323896-how-to-put-custom-body-on/#findComment-1634845 Share on other sites More sharing options...
edmon Posted September 7 Author Share Posted September 7 On 9/6/2024 at 11:18 PM, requinix said: You have code that is able to get their location. You need to take that location data and put it into the link at that time - you can't put it in there ahead of time. Take a look at MDN's geolocation examples for something that's actually very close to what you want to do. Hi there. Yes I got the location. But I have no idea how to call the that link outside of the <script> tab. Using Js or imap or what can I use? Any suggestion please Quote Link to comment https://forums.phpfreaks.com/topic/323896-how-to-put-custom-body-on/#findComment-1634876 Share on other sites More sharing options...
Solution dodgeitorelse3 Posted September 7 Solution Share Posted September 7 (edited) if you go to the link requinix posted and click the play button in the result window to see just how the link is created. Edited September 7 by dodgeitorelse3 typo Quote Link to comment https://forums.phpfreaks.com/topic/323896-how-to-put-custom-body-on/#findComment-1634884 Share on other sites More sharing options...
dodgeitorelse3 Posted September 10 Share Posted September 10 My post should not have been marked as the solution. requinix should be marked as such. He gave you the answer. You just didn't look completely at the link he provided. Glad you got it sorted though. 1 Quote Link to comment https://forums.phpfreaks.com/topic/323896-how-to-put-custom-body-on/#findComment-1635007 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.