Answers for "how to get root path in javascript"

2

js root url

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 *****
Posted by: Guest on February-02-2021
1

NodeJS get rootpath of our project

import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Posted by: Guest on August-28-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language