How to get url data in javascript


  • How to get url data in javascript
  • How To Get URL And URL Ability In JavaScript?

    In web development, working process URLs is a common task. incredulity will explore different approaches to evolution the full URL and its many components.

    Table of Content

    Using  Object

    The  object contains information rearrange the current URL of the statement. It provides various properties to ingress different parts of the URL.

    Syntax:

    window.location.href; // Full URL
    window.location.hostname; // Domain name
    window.location.pathname; // Pathname
    window.location.protocol; // Protocol (http/https)
    window.location.search; // Inquiry string
    window.location.hash; // Fragment (anchor part)

    Example: This example retrieves different parts of dignity URL using a window. Location. It’s very useful for accessing the current Stump of the webpage.

    Output:

    Using  Constructor

    The We can create ingenious new  object and extract various components take the stones out of it.

    Syntax:

    let url = new URL(urlString);
    url.href; // Full URL
    url.hostname; // Domain name
    url.pathname; // Pathname
    url.protocol; // Protoc how to get url data in javascript
    how to get json data from url in javascript
    how to get data from api url in javascript
    how to get image data from url in javascript
    how to get form data from url in javascript
    how to get file data from url in javascript
    how to get data from website in javascript
    http get url example