Languages
[Edit]
EN

JavaScript - check if URL is internal

9 points
Created by:
Reilly-Collier
860

In this short article, we would like to show how to use JavaScript, to check if URL is internal.

As an internal URL we understand the URL that indicates some webpage or resource on the same website on what was placed.

Practical example:

Note: the solution uses location.origin property that is available in web browsers only.

Note: in the above example, URLs are tested as internal, according to the current origin - Dirask origin.

 

Custom origin cases

Edit

URL can be internal according to indicated origin.

It means:

Practical example:

 

See also

Edit
  1. JavaScript - check if URL is external

Alternative titles

  1. JavaScript - check if link is internal
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join