超链接中的“&"号导致W3C验证失败 [英] Ampersands in hyperlinks cause W3C validation to fail

查看:61
本文介绍了超链接中的“&"号导致W3C验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题.我编写符合标准的好代码,只是为了使它在某些超链接URL中由于&"号而失败.

I have a reacurring problem. I code nice standards compliant code only to have it fail due to ampersands within some of the hyperlink urls.

任何人都知道解决方法或为此破解吗.

Does anyone know of a work around or hack for this.

谢谢

推荐答案

您应 URL编码超链接,因此所有字符都将转换为有效的ASCII格式,并且不包含任何(X)HTML实体.

You should URL Encode the hyperlinks, so all characters are turned into a valid ASCII format and don't contain any (X)HTML entities.

对于C#,请使用 HttpUtility.UrlEncode ,对于PHP urlencode ,对于JavaScript encodeURI ,等等...为您使用的语言找到正确的方法并不难.

For C# use HttpUtility.UrlEncode, for PHP urlencode, for JavaScript encodeURI, etc... Finding the right method for the language you're using shouldn't be that hard.

这篇关于超链接中的“&"号导致W3C验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆