2016-11-03 2 views
1

ナビゲーションジオロケーションから緯度と経度を取得しようとしていますが、コードはChromeでのみ動作します... Operaで試しましたが、警告は表示されませんここは私のページですhttps://codepen.io/Juan1417/pen/zKZkxyGeolocationはChromeでのみ動作します

$(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>

+0

というエラーがあなたの問題とは何の関係もありません。 – ceejayoz

+0

申し訳ありませんが、以前はエラーでした – Juan

答えて

1

オペラは、他のブラウザと同様に、ジオロケーションサービスを使用するユーザー許可権限が必要です。

初めてジオロケーション情報をリクエストするウェブサイトにアクセスすると、Googleロケーションサービスの利用規約が提示されます。同意すると、サービスが有効になります。

その後、ウェブサイトからジオロケーション情報が要求されるたびに、オペラがあなたに指示し、あなたのロケーションデータを送信するか、送信しないかを選択できます。

ジオロケーションへのアクセスのリクエストを承認していない可能性があります。この場合、if (navigator.geolocation)falseと評価されるため、コードは実行されません。

ジオロケーションサービスを再度有効にするには、次の手順に従います。

あなたは、まずGoogleの場所サービス契約条件を拒否したが、後にあなたの心を変え、Settings > Preferences > Advanced > Networkに行き、Enable geolocationを確認してください。

これらの命令は、ここに発見された:http://help.opera.com/FreeBSD/11.10/en/geolocation.html

+0

ナビゲータは常にジオローカライゼーションを許可するように頼み、許可を選択しました。 – Juan

+0

@Juan 'console.log(navigator.geolocation)'ならばコンソールは何を言うのですか? 'undefined'と言うと、それは許されません。 – Soviut

+0

また、答えのネットワーク設定とは何ですか?実際に有効になっていることを確認してください。 – Soviut

関連する問題