- 2008-06-22 (日) 23:08
- 未分類
Lightbox2はaタグだけではなく、areaタグにも使えるのですが、
aタグ同様rel属性値を”lightbox”としてしまうと、xhtml validにはなりません。
というわけで、回避手段としてrel属性の代わりに汎用属性であるlang属性を使うようLightbox2のソースコードを変更します。
あまりお勧めできる方法ではありませんので、ご参考程度にどうぞ。
以下はlightbox2.04のソースです。
・lightbox.js 191行目を変更
var target = event.findElement(’a[rel^=lightbox]‘) || event.findElement(’area[rel^=lightbox]‘);
↓
var target = event.findElement(’a[rel^=lightbox]‘) || event.findElement(’area[lang^=lightbox]‘);
・lightbox.js 216 - 227行目を変更
if ((imageLink.rel == ‘lightbox’)){
// if image is NOT part of a set, add single image to imageArray
this.imageArray.push([imageLink.href, imageLink.title]);
} else {
// if image is part of a set..
this.imageArray =
$$(imageLink.tagName + ‘[href][rel="' + imageLink.rel + '"]‘).
collect(function(anchor){ return [anchor.href, anchor.title]; }).
uniq();
while (this.imageArray[imageNum][0] != imageLink.href) { imageNum++; }
}
↓
if (imageLink.rel) {
if ((imageLink.rel == ‘lightbox’)){
// if image is NOT part of a set, add single image to imageArray
this.imageArray.push([imageLink.href, imageLink.title]);
} else {
// if image is part of a set..
this.imageArray =
$$(imageLink.tagName + ‘[href][rel="' + imageLink.rel + '"]‘).
collect(function(anchor){ return [anchor.href, anchor.title]; }).
uniq();
while (this.imageArray[imageNum][0] != imageLink.href) { imageNum++; }
}
} else if (imageLink.lang) {
if ((imageLink.lang == ‘lightbox’)){
// if image is NOT part of a set, add single image to imageArray
this.imageArray.push([imageLink.href, imageLink.title]);
} else {
// if image is part of a set..
this.imageArray =
$$(imageLink.tagName + ‘[href][lang="' + imageLink.lang + '"]‘).
collect(function(anchor){ return [anchor.href, anchor.title]; }).
uniq();
while (this.imageArray[imageNum][0] != imageLink.href) { imageNum++; }
}
}
属性値”lightbox[xxx]“の書式もvalidにならないので、
lang=”lightbox.xxx”とします。
- Newer: wordpressテーマ変更
Trackbacks:0
- Trackback URL for this entry
- http://www.rokkoen.jp/wordpress/2008/06/22/lightbox2%e3%81%a7area%e3%82%bf%e3%82%b0%e3%81%abrel%e5%b1%9e%e6%80%a7%e3%82%92%e4%bd%bf%e3%81%86%e3%81%a8xhtml-valid%e3%81%ab%e3%81%aa%e3%82%89%e3%81%aa%e3%81%84/trackback/
- Listed below are links to weblogs that reference
- Lightbox2でareaタグにrel属性を使うとxhtml validにならない from webサイト構築メモ