简体   繁体   English

prettyPhoto的rel属性上的验证错误

[英]validation error on prettyPhoto's rel attribute

It is looks like W3C's validator return a validation error on prettyPhoto's rel attribute for HTML5 pages. 看起来W3C的验证器在prettyPhoto的rel属性中为HTML5页面返回了验证错误。 How do I solve this error? 我该如何解决这个错误?

Bad value prettyPhoto[gallery1] for attribute rel on element a: Keyword prettyphoto[gallery1] is not registered. 元素a上的属性rel的值valuePhoto [gallery1]的值错误:关键字prettyphoto [gallery1]未注册。

Many thanks! 非常感谢!

Using rel attribute with non-proposed (thus not allowed) values not valid for HTML5 markup. rel属性与对HTML5标记无效的非建议(因此不允许)值一起使用。 Value prettyPhoto is not in the list of proposed values. prettyPhoto不在建议值列表中。 So you may face the difficulties with getting your web-page with image gallery passing validation. 因此,使用图库通过验证来获取网页可能会遇到困难。

A Possible Solution: 可能的解决方案:

  1. Open jquery.prettyPhoto.js (presumably non-minified one) and perform find & replace function of your text-editor: 打开jquery.prettyPhoto.js (可能是未缩小的)并执行文本编辑器的查找和替换功能:

    replace all occurrences of attr('rel') with attr('data-gal') . attr('data-gal')替换所有出现的attr('rel') attr('data-gal')

  2. In your gallery code use: 在您的图库代码中使用:

    data-gal="prettyPhoto[galname]"

    instead of: 代替:

    rel="prettyPhoto[galname]"

  3. Initialize your prettyPhoto with: 使用以下方法初始化prettyPhoto:

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

    And you are on the right way for getting your code valid! 而且您将以正确的方式使代码有效!

You can also read this article with this possible solution. 您还可以阅读本文 ,了解这种可能的解决方案。

You can use the (undocumented) hook setting as mentioned in the comments here . 您可以使用此处注释中提到的(未记录) hook设置。

Specify your links like this: <a href="img.jpg" data-gal="prettyPhoto[gal]"></a> and use $("a[data-gal^='prettyPhoto'").prettyPhoto({hook: 'data-gal'}); 像这样指定链接: <a href="img.jpg" data-gal="prettyPhoto[gal]"></a>并使用$("a[data-gal^='prettyPhoto'").prettyPhoto({hook: 'data-gal'}); to initialize prettyPhoto. 初始化prettyPhoto。

You can also fix it by updating the settings to use the class hook: 您还可以通过更新设置以使用类挂钩来解决此问题:

s = jQuery.extend({
        ...
        hook: "rel",
        animation_speed: "fast",
        ajaxcallback: function() {},
        slideshow: 5e3,
        autoplay_slideshow: false,
        opacity: .8,
        ...

to: 至:

s = jQuery.extend({
        ...
        hook: "class",
        ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM