You're calling too many functions at the wrong time and trying to document.write() in the wrong place.
1. getLocation() does not return anything. Don't call it as an argument to another function.
2. showPosition() does not return anything either. Don't call it as an argument to another function.
3. You can't write the location until showPosition(), being the callback you gave to getCurrentPosition(). Any time before that, you don't have the location information yet.
Just call getLocation().
And when this is working, stop using document.write and document.writeln and use the modern method: run this code on document load, then show the location by getting an element and changing it's contents.
<p id="locale"></p>
<script>
var x = document.getElementById("locale");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}