Friday, June 22, 2018

Get URL and URL Parts in JavaScript | Get an Absolute URL with JavaScript | How to get the exact href value only without their domain | How to check if any Link is for some specific domain | Link attribute HOST > PATHNAME > Filter links by domain | host name

I'm having trouble in getting the exact value of href only
It's a little known (maybe) fact that most browsers convert Anchor node elements into Location objects as well. So you can access all parts available to Location too;
Suppose consider below html code:
<body>
HELLO '59 IS PRESENT <a href="test2.html">HI</a>
<a href="https://stackoverflow.com/questions/domain">Another LINK</a>
</body>
In above html, two link exists, one for self domain and another for stackoverflow, now if I look through them, below output would be generated:
PROTOCOL=http:, HOST=localhost, PORT=
LINK PATH=/test2.html

PROTOCOL=https:, HOST=stackoverflow.com, PORT=
LINK PATH=/questions/domain

No comments:

Post a Comment