Get absolute URL using Javascript

Below is the simple method to get absolute URL using javascript. This code can be run on the Browser Console directly. Open the developer tools and navigate to console tab and paste the below function to test the snippet.

Sample Code Get Absolute URL using Javascript

How to read the current URI in parts?

Let us take an example of the current URL…ing-javascript/ ‎

To get the complete URL, we can concat the above code as shown below.

You may also like...

1 Response

  1. Ahmad Maleki says:

    Absolutely Useful! Thank you very much.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.