我试图从导航地理定位中获取纬度和经度,但代码仅适用于Chrome ...我在Opera中试过,但警报未显示 这是我的页面: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);
});
}
});
&#13;
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;
}
&#13;
<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>
&#13;
答案 0 :(得分:1)
首次访问要求地理位置信息的网站时,会显示Google位置服务的条款和条件。如果您同意,则会激活该服务。
之后,每当网站请求地理位置信息时,Opera会告诉您,并为您提供选择:发送您的位置数据,或者不发送它。
您很可能不会批准访问地理位置的请求。如果是这种情况,则没有任何结果,因为您的if (navigator.geolocation)
将评估为false
,因此内部代码永远不会运行。
要重新启用地理定位服务,请按照以下说明操作。
如果您最初拒绝Google位置服务的条款和条件,但稍后改变主意,请转到
Settings > Preferences > Advanced > Network
,然后选中Enable geolocation
。
这些说明可在此处找到:http://help.opera.com/FreeBSD/11.10/en/geolocation.html