prettyPhoto的rel属性验证错误

5 html5

看起来像W3C的验证器在prettyPhoto的HTML5页面的rel属性上返回验证错误.我该如何解决这个错误?

属性rel的元素a的错误值prettyPhoto [gallery1]:关键字prettyphoto [gallery1]未注册.

非常感谢!

Ahs*_*hid 10

使用rel具有非建议(因此不允许)值的属性对HTML5标记无效.值prettyPhoto不在建议值列表中.因此,您可能会遇到使用图像库传递验证的网页时遇到的困难.

可能的解决方案:

  1. 打开jquery.prettyPhoto.js(大概非精缩一个),并执行查找和替换文本编辑器的功能:

    替换所有出现的attr('rel')attr('data-gal').

  2. 在您的图库代码中使用:

    data-gal="prettyPhoto[galname]"

    而不是:

    rel="prettyPhoto[galname]"

  3. 使用以下内容初始化您的prettyPhoto:

    jQuery("a[data-gal^='prettyPhoto']").prettyPhoto();

    您正确地获得代码的正确方法!

您还可以使用此可能的解决方案阅读本文.


Cry*_*zon 9

您可以使用此处hook注释中提到的(未记录的)设置.

像这样指定你的链接:<a href="img.jpg" data-gal="prettyPhoto[gal]"></a>并用于$("a[data-gal^='prettyPhoto'").prettyPhoto({hook: 'data-gal'});初始化prettyPhoto.