Browser misinterprets '& not' in URL

Apparently, if the URL containing the ¬ text is used as part of the field property, many browsers will interpret this as '¬' , So this HTML code:

 <a href="#" onclick="window.location='http://www.example.com?some_param=1&notify=true';">Click here</a> 

will display as:

 <a href="#" onclick="window.location='http://www.example.com?some_param=1¬ify=true';">Click here</a> 

I found a couple of alternatives, replacing ¬ with &%6Eot or POSTing with a form instead of GETting a parameterized URL. But POST is not always a good alternative, and a replacement is admittedly a hack - it will also have to deal with other common tokens: ¢ , ¤ , £ , § , © , ® ... (list from here ).

Surely someone has a better solution for this?

+8
html browser html-parsing
source share
1 answer

Elemental attributes are interpreted by the HTML parser, so you should avoid the & characters like &amp; . It works most of the time, even if you don’t, but in some cases (like yours) you have to do it “correctly” or it won’t work.

+11
source share

All Articles