js get base url
var url = window.location.origin;console.log(window.location.origin);var base_url = window.location.origin;
var host = window.location.host;
var pathArray = window.location.pathname.split( '/' );
suppose that you have a page with this address: http://sub.domain.com/virtualPath/page.htm. use the following in page code to achive those results:
window.location.host : you'll get sub.domain.com:8080 or sub.domain.com:80
window.location.hostname : you'll get sub.domain.com
window.location.protocol : you'll get http:
window.location.port : you'll get 8080 or 80
window.location.pathname : you'll get /virtualPath
window.location.origin : you'll get http://sub.domain.com *****
Also in JavaScript:
- ad data to js object
- jquery check checkbox
- i18n react meta description
- how to send json data in fetch request body
- toggle class to an element javascript
- mac os chrome opne debug new tab
- how to get tomorrow date in javascript
- autoformat mobile number (xxx) xxx-xxx codepen
- Enclose in Brackets
- change windlow location relitave to current one
- js query string
- index of value in array
- document queryselectorall and map javacript
- node biology definition
- how to go back one directory in git bash
- puppeteer block request javascript
- js unspecified parameters
- nodemailer
- angular two datepickers
- javascript get element position relative to document
- javascript appendchild at index
- destruction in javascript
- selector id jquery but is variable
- reqeuest body in hapijs