Saturday, April 13, 2024
 Popular · Latest · Hot · Upcoming
33
rated 0 times [  35] [ 2]  / answers: 1 / hits: 17025  / 14 Years ago, fri, october 15, 2010, 12:00:00

I'm building a JS library which has a requirement of looking at form[action] and a[href] values and resolving them into absolute URLs.


For example, I'm on http://a/b/c/d;p?q and encounter an href value of "../g" (assume there's no <base> element). The resulting absolute would be: http://a/b/g.


Is there a JS library that does this already? I'd have to believe so.


For more info about what's needed, the spec:
https://www.rfc-editor.org/rfc/rfc3986#section-5.4


More From » html

 Answers
5

It turns out that the .href attribute of a A element (not .getAttribute('href'), but .href) returns the resolved (absolute) URL.


[#95308] Wednesday, October 13, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
destanyb

Total Points: 407
Total Questions: 88
Total Answers: 88

Location: Senegal
Member since Mon, Sep 5, 2022
2 Years ago
;