Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

How to get current URL with Javascript or React

const currentURL = window.location.href // returns the absolute URL of a page

const pathname = window.location.pathname //returns the current url minus the domain name
Comment

get url react

window.location.href
Comment

get current url react router

import {withRouter} from 'react-router-dom';

const SomeComponent = withRouter(props => <MyComponent {...props}/>);

class MyComponent extends React.Component {
  SomeMethod () {
    const {pathname} = this.props.location;
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript check for undefined 
Javascript :: jquery ajax form submit 
Javascript :: full width of image and maintain aspect ratio react native 
Javascript :: javacript contextmenu preventDefault 
Javascript :: node js create folder 
Javascript :: vanilla js on click 
Javascript :: how to get the first key in a n object in javascript 
Javascript :: jquery get the length of input text 
Javascript :: Slick slider arrows change 
Javascript :: remove apex chart toolbar 
Javascript :: regular expression to remove empty lines after text 
Javascript :: how to Store Objects in HTML5 localStorage 
Javascript :: git ignore .env files not working 
Javascript :: js check for url parameter 
Javascript :: upgrade node version ubuntu 
Javascript :: datatable scroll horizontal 
Javascript :: puppeteer headless false 
Javascript :: javascript first and last day of the month 
Javascript :: react native image fit container 
Javascript :: automatically scroll to bottom of page 
Javascript :: how to get year in react 
Javascript :: jquery get option data attribute 
Javascript :: phone number validation in yup 
Javascript :: js scrolling in div 
Javascript :: minus month javascript date 
Javascript :: url validator javascript 
Javascript :: node express server static files 
Javascript :: babel cdn react 
Javascript :: jquery show for 5 seconds 
Javascript :: javscript remove last character 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =