im trying to get the latitude and the longitude from the navigation geolocation, but the code only works in Chrome... i tried in Opera but the alert is not shown here is my page: https://codepen.io/Juan1417/pen/zKZkxy
$(document).ready(function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
alert("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
});
}
});
span {
font-weight: bold;
color: blue;
}
body {
background-color: white;
padding: 30px;
}
.img-center {
margin: 0 auto;
border-color: black;
border-width: 4px;
border-style: double;
border-radius: 30px;
}
.title1 {
font-family: Lobster;
color: red;
}
.title2 {
font-family: Amatic SC;
color: green;
}
#d11 {
border-style: outset;
border-width: 10px
}
#d112 {
border-style: inset;
}
<link href="https://fonts.googleapis.com/css?family=Lobster|Amatic+SC" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<div class="container-fluid">
<div id="d11"class="well">
<div id="d111" class="text-center">
<h1 class="title1">Alexander Fleming</h1>
<h2 class="title2">10 facts about the man that started the Antibiotic Revolution</h2>
</div>
<div id="112" class="well text-center">
<img src="https://lanaveva.files.wordpress.com/2010/03/alexander_fleming.png"class="img-responsive center-block img-center">
</img>
<p><br><strong>Fleming working in his laboratory.</strong></p>
</div>
<ul>
<li><p><span>Alexander Fleming Fact 1:</span>
Alexander Fleming was born on August 6th 1881 and during the 19th century period in history when scientific discoveries were being made and innovations in mathematics, physics, biology, electricity and chemistry were moving very fast.
</p>
</li>
<li><p><span>Alexander Fleming Fact 2:</span>
After Alexander Fleming finished his education he worked in a shipping office until he was twenty years old.
</p>
</li>
<li><p><span>Alexander Fleming Fact 3:</span>
Tom, his older brother, had become a physician and would encourage his brother to follow the same path.
</p>
</li>
<li><p><span>Alexander Fleming Fact 4:</span>
In 1903 Fleming began his medical training at St Mary’s Hospital Medical School located in Paddington. By 1906 he had qualified with a distinction on his MBBS degree.
</p>
</li>
<li><p><span>Alexander Fleming Fact 5:</span>
Since 1900 Fleming had been in the Volunteer Force as a private in the London Scottish Regiment. While attending medical school he had joined the rifle club there and the club captain suggested he apply to the research department of St Mary’s.
</p>
</li>
<li><p><span>Alexander Fleming Fact 6:</span>
This he did and would become the assistant to Sir Almoroth Wright a bacteriologist and pioneer in immunology and vaccine therapy.
</p>
</li>
<li><p><span>Alexander Fleming Fact 7:</span>
When the First World War broke out he became a captain in the Royal Army Medical Corps working in the hospitals on the battlefields of the Western Front.
</p>
</li>
<li><p><span>Alexander Fleming Fact 8:</span>
Having been away from his laboratory during the summer month of August, upon his return he found his stack of staphylococci cultures that he had left stacked on a corner bench, showed one of the cultures had been contaminated with a fungus.Upon further examination the colonies of staphylococci directly around the fungus were gone but in other areas where there was no fungus were as normal.Having identified the moulds origins as coming from the Penicillium genus and he would eventually call the substance penicillin, in the meantime he had taken to calling it “mould juice”. He continued with his research and experiments to see what could be achieved with this new discovery.
</p>
</li>
<li><p><span>Alexander Fleming Fact 9:</span>
Alexander Fleming once said "When I woke up just after dawn on September 28, 1928, I certainly didn't plan to revolutionise all medicine by discovering the world's first antibiotic, or bacteria killer, but I suppose that was exactly what I did."
</p>
</li>
<li><p><span>Alexander Fleming Fact 10</span>
-On March the 11th Alexander Fleming dies of a heart attack at his home in London at the age of seventy three.</p>
</li>
</ul>
<blockquote>"Penicilline cures, but wine makes people happy"
<footer>Alexander Fleming</footer>
</blockquote>
<p>If you want more information about Alexander Fleming
<a target="_blank" href="https://es.wikipedia.org/wiki/Alexander_Fleming">click here.</a>
</p>
</div>
Opera, like other browsers, requires the user grant permission to use the geolocation service.
The first time you go to a website that requests geolocation information, Google Location Services' terms and conditions are presented. If you agree to them, the service is activated.
After that, every time a website requests geolocation information, Opera tells you, and gives you a choice: to send your location data, or not to send it.
You most likely did not approve the request for access to geolocation. If this is the case, nothing happens because your if (navigator.geolocation)
will evaluate as false
so the code inside is never run.
To re-enable the geolocation service, follow these instructions.
If you at first reject Google Location Services' terms and conditions, but later change your mind, go to
Settings > Preferences > Advanced > Network
, and checkEnable geolocation
.
These instructions were found here: http://help.opera.com/FreeBSD/11.10/en/geolocation.html