Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <!-- Js Geolacation API -->
<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <title>Geolocation API</title>

<h2> Geolocation API in Javascript</h2>

<p>Click the green button to get your coordinates. Make sure to allow your browser to share your location</p>

<button onclick="getLocation()">Try Me</button>

<p id="demo"></p>


<a style="all:unset;font-family: Roboto, arial, sans-serif;font-size: 20px;width: 100%;text-align: center;display: block;background: linear-gradient(135deg,#001634 10%,#2e143e);line-height: 50px;color: white;position: absolute;top: 0;left: 0;right: 0;text-decoration: none;cursor:pointer;z-index: 9999;" target="_blank" href="">Made With ❤️ Click this banner to checkout more on Geolocation API --></a>


                button {
  background-color: green;
  color: white;
  padding: 16px 20px;
  border: none;
  cursor: pointer;
  opacity: 0.8;
  position: fixed;
  bottom: 23px;
  right: 28px;
  width: 280px;



                const x = document.getElementById("demo");

function getLocation() {
  try {
    navigator.geolocation.getCurrentPosition(showPosition, showError);
  } catch {
    x.innerHTML = err;

function showPosition(position) {
  x.innerHTML =
    "Latitude: " +
    position.coords.latitude +
    "<br>Longitude: " +

function showError(error) {
  switch (error.code) {
    case error.PERMISSION_DENIED:
      x.innerHTML = "User denied the request for Geolocation.";
      x.innerHTML = "Location information is unavailable.";
    case error.TIMEOUT:
      x.innerHTML = "The request to get user location timed out.";
    case error.UNKNOWN_ERROR:
      x.innerHTML = "An unknown error occurred.";