Our URL
www.nicadpower.com/index.com
but we only want to get the path after www.nicadpower.com, which
index.com
how can we get index.com using window.location and jquery
I think you want
window.location.pathname
This will give you /index.com
To get rid of the leading /, you can simply use the substring:
window.location.pathname.substring(1);
Here is another trick you can use. You can split the parts of the path using the split method, for example:
If you have a URL: www.nicadpower.com/posts/2012
www.nicadpower.com/posts/2012
Usage: window.location.pathname.split('/')
window.location.pathname.split('/')
You will give: ["", "posts", "2012"]
["", "posts", "2012"]
Source: https://habr.com/ru/post/890806/More articles:JQuery HTML5 input - javascriptChoosing a computer on the local network to work as a server - c ++PHP URL for linking to Regex - hrefTurning plain text urls into active links using PHP - htmlDataBinding for WinForm - c #how to get binary values โโof bytes stored in a byte array - javaA very simple Python question (strings, formats, and screens) - pythonTwo 1 - N relationships in Mongoid (Rails) - ruby-on-railshow to clean up in node.js - node.jsRuby Passenger: no such file to download the package - ruby โโ| fooobar.comAll Articles