Submit Your Article Forum Rules

Results 1 to 1 of 1

Thread: Overcoming Lightbox Plus validation issues

  1. #1
    Administrator weegillis's Avatar
    Join Date
    Oct 2003
    Posts
    5,789

    Overcoming Lightbox Plus validation issues

    Users of Lightbox Plus (lightbox_plus.js written by Takuya Otani) will crash into the "unregistered value for rel attribute in a" wall when attempting to validate HTML5. The meta data will trip the switch, too.

    HTML Code:
    <head>
     .
     .
     <meta name="X-Resource-Dir" content="/resource/">
     <meta name="X-Script-Dir" content="/resource/">
    </head>
    This is a work around:
    Code:
    JavaScript
    
    function lightboxInit()
    {
     var headElement = document.getElementsByTagName('head')[0];
     var m1 = document.createElement('meta');
         m1.setAttributeNode(attr('name',"X-Resource-Dir"));
         m1.setAttributeNode(attr('content',"/resource/"));
         headElement.appendChild(m1);
     var m2 = document.createElement('meta');
         m2.setAttributeNode(attr('name',"X-Script-Dir"));
         m2.setAttributeNode(attr('content',"/resource/"));
         headElement.appendChild(m2);
     var lb1 = document.getElementById('potofgold');
         lb1.rel = "lightbox external";
    }
    
    // dependency = attr()
    
    function attr(x,y)
    {
     var z = document.createAttribute(x);
         z.nodeValue = y;
         return z;
    }
    This can be either a body onload or an onload event, but I recommend it be at the top of the execution queue. My implementation uses Dean Edwards addEvent() to manage the onload events.

    HTML Code:
    <script src="/js/dhtml.js"></script>
    <script><!--
    addEvent(window,"load",function()
     {
      lightboxInit();
     }
    );
    //--></script>
    <script src="/resource/spica.js"></script>
    <script src="/resource/lightbox_plus.js"></script>
    </body>
    </html>
    My source code HTML reads,
    HTML Code:
    <a href="http://www.example.org/downloads/pot-of-gold_wp.jpg" id="potofgold" rel="external" title="Pot of Gold photo by __Me__ Copyright 2006">&nbsp;</a>
    but renders,
    HTML Code:
    <a href="http://www.example.org/downloads/pot-of-gold_wp.jpg" id="potofgold" rel="lightbox external" title="Pot of Gold photo by __Me__ Copyright 2006">&nbsp;</a>
    Last edited by weegillis; 08-20-2011 at 11:47 AM. Reason: rendering; omissions

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •