javascript - Strange characters in Htmt view -


i have javascript following

<script type="text/javascript">   var login = "<sec:authentication property="principal.username"/>"; </script> 

when see value of login is

abc&#64;gmail&#46;com.  

what want must abc@gmail.com.

is there way can correct lo-gin , not weird symbols. know why such weird symbols occurring instead of proper symbols.

&#64; , &#46; html codes @ , . respectively.

as far know there isin't native function decode such string in javascript. can use parsing ability of dom elements.

var login = (login = document.createelement('span'), login.innerhtml = 'abc&#64;gmail&#46;com', login.textcontent); 

you can wrap functionality in function reuse:

function decodehtml(text) {     var el = document.createelement('span');      return el.innerhtml = text, el.textcontent;  }  decodehtml('abc&#64;gmail&#46;com'); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -