Languages
[Edit]
EN

JavaScript - check if URL is external

9 points
Created by:
MindOfMadness3
696

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

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 external, according to current origin - Dirask origin.

 

Custom origin cases

Edit

URL can be external according to indicated origin.

It means:

Practical example:

 

See also

Edit
  1. JavaScript - check if URL is internal

Alternative titles

  1. JavaScript - check if link is external
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