I have a list of URLs that our users entered for sites of different clients ... I load this list from the server into the grid so that users can see ... I made the URLs interactive by wrapping their href HTML tag .. The problem is that sometimes the user enters URLs without http: // or www. prefix, so the browser treats them as relative URLs that never happen because all of these websites are for our customers and they are all external. Is there a way to make these URLs be considered absolute rather than relative?
Here is an example:
<a target='_blank' href='google.com'>google.com</a>
If you try this, you will see that the browser assumes that this is a relative path that should not be.
thanks
Decision:
I chose to check "//" (because I donβt know what the protocol is) maybe http or https), and if not found, I assume that this is an http site, and I prefix the URL with that - so shorter than anyone way to not force the browser to treat hyperlinks as absolute
Ayyoudy
source share