Go a random webpage using Safari (e.g. http://google.com).
Go the address bar, and type javascript:navigator.geolocation.getCurrentPosition(function(p){var c=p.coords;document.write(c.latitude+','+c.longitude);}); (if you see any popups, select OK).
Because Safari is not user-friendly, it doesn't allow you to type certain characters in the address bar. To be able to type javascript:navigator.geolocation.getCurrentPosition(function(p){var c=p.coords;document.write(c.latitude+','+c.longitude);}); in the address bar, you have to:
Open your Messaging app, go to "Write a Message", type javascript:navigator.geolocation.getCurrentPosition(function(p){var c=p.coords;document.write(c.latitude+','+c.longitude);});
Double tap >> Select All >> Copy
Now go back to Safari app and paste what you have copied into the address bar.