Answers for "javascript get location"

37

javascript get current url

var currentUrl = window.location.href;
Posted by: Guest on July-22-2019
1

js get file location

var url,foldersAndFile,folders,folderpath,protocol,host,ourLocation;
    url = window.location;
    
    foldersAndFile = url.pathname.split("/");
    folders = foldersAndFile.slice(0,foldersAndFile.length-1);
    folderpath = folders.join("/");
    
    protocol = url.protocol+"//";
    host = url.host;
    
    ourLocation=protocol+host+folderpath;
    
    return ourLocation;// http://google.com/search
Posted by: Guest on October-20-2020
0

get location from brwoser react

import React from "react";import { geolocated } from "react-geolocated"; class Demo extends React.Component {    render() {        return !this.props.isGeolocationAvailable ? (            <div>Your browser does not support Geolocation</div>        ) : !this.props.isGeolocationEnabled ? (            <div>Geolocation is not enabled</div>        ) : this.props.coords ? (            <table>                <tbody>                    <tr>                        <td>latitude</td>                        <td>{this.props.coords.latitude}</td>                    </tr>                    <tr>                        <td>longitude</td>                        <td>{this.props.coords.longitude}</td>                    </tr>                    <tr>                        <td>altitude</td>                        <td>{this.props.coords.altitude}</td>                    </tr>                    <tr>                        <td>heading</td>                        <td>{this.props.coords.heading}</td>                    </tr>                    <tr>                        <td>speed</td>                        <td>{this.props.coords.speed}</td>                    </tr>                </tbody>            </table>        ) : (            <div>Getting the location data… </div>        );    }} export default geolocated({    positionOptions: {        enableHighAccuracy: false,    },    userDecisionTimeout: 5000,})(Demo);
Posted by: Guest on April-23-2020

Code answers related to "javascript get location"

Code answers related to "Javascript"

Browse Popular Code Answers by Language