Get the output of a function..

 
0
 

Hello :D
Im 100% noob to javascript..

now, i have this script:

<script>
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
document.write(position.coords.latitude + '_' + position.coords.longitude);
});
} 
</script>

and i need to send the location data to a php script..
Is there any easy and smart way to do souch things?

The easy way will be to redirect to ?data=OUTPUT FROM GEOLOCATION FUNCTION
But how do i do that??

i have tried this, without success:

<script>
    if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
    window.location=("http://mypage.com/?data=position.coords.latitude + '_' + position.coords.longitude");
    });
    } 
 </script>

But it just send me to a page named: http://mypage.com/?data=position.coords.latitude%20+%20'_'%20+%20position.coords.longitude

i want it to send me to: http://mypage.com/?data=55.673514_12.465726

How do i do that?? :D

Regards Lasse

Featured Replies in this Discussion

  • ... It's because u put it in quotation marks as a string. Change it to ... That should do it.
    Post Contains: Links Code
 
2
 

window.location=("http://mypage.com/?data=position.coords.latitude + '_' + position.coords.longitude");
It's because u put it in quotation marks as a string. Change it to
window.location=("http://mypage.com/?data=" + position.coords.latitude + "_" + position.coords.longitude);
That should do it.

 
0
 

Thank you mann..

it works :D

 
0
 

Np, mark the question solved please!

Question Answered as of 2 Years Ago by NardCake
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article