We can get the full URL of the current page by using location object , Here is the syntax.
Sample code is here.
<script language='JavaScript' type='text/JavaScript'>

The output is here

Path upto the script root

We can get path of the URL upto the root of the page by using slice and lastIndexOf function

Here it is
var path=location.href;
var ind=path.lastIndexOf("/");
var root_path=path.slice(0,ind);
Output is here
JavaScript location Getting hostname Refresh the page
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net


    Post your comments , suggestion , error , requirements etc here

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer