Reputation: 85
I am trying to incorporate the user's current longitude and latitude into an iframe url. My code is below.
<script>
var lat = position.coords.latitude;
var lon = position.coords.longitude;
document.write('<iframe src=http://weather.wdtinc.com/imap/imap5/?&INIT_LAT='+lat+'&INIT_LON='+lon+'> </iframe>');
</script>
This just gives me a blank page. Does anyone know what I am doing wrong?
Upvotes: 0
Views: 100
Reputation: 133360
You missed quote in src
navigator.geolocation.getCurrentPosition(function(position) {
document.write('<iframe src="http://weather.wdtinc.com/imap/imap5/?&INIT_LAT=' +
position.coords.latitude+
'&INIT_LON='+
position.coords.longitude+'" > </iframe>');
});
Upvotes: 2