html - Anchor Tag Not working -


i have 2 anchor tag below

<a href="www.exx.com" target="_blank">             annualbudget</a> 

when click above anchor tag ,its not gone correct url(for it's gone mydomainname/www.exx.com). same time below anchor tag working , go correct url .

<a href="https://www.exx.com" target="_blank">             annualbudget</a> 

why www not worked https worked ? , how can solve issue ?

update :

  • the url entered user in textbox .so how can check ?

try putting "http://" in front.

i.e.

<a href="http://www.exx.com" target="_blank">annualbudget</a> 

"www" not protocol/scheme. https or http protocols.

absolute urls have have "scheme" in front, see details urls on wikipedia.

alternatively, work:

<a href="//www.exx.com" target="_blank">annualbudget</a> 

update 1:

since comment input comes user, let me add one:

enter image description here

(although refers sql injection, same true all user input).

update 2:

to check input absolute url, like:

// read user input, e.g. (webforms syntax!): string = mytextbox.text.trim();  // checking (this has done more thoroughly in real-life!) if ( !my.startswith("http://") && !my.startswith("https://") ) {     = "http://" + my; }  // "my", e.g. (again, webforms syntax only): myhyperlink.navigateurl = my; 

(please note i'm no mvc expert, above pseudo-code uses webforms syntax instead)


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -