FrontPage
Rev.8を表示中。最新版はこちら。
IEでサイト・ドメイン別ユーザースタイルシートの適用を可能にする。最初の目的は、HTMLヘルプ(.chmファイル)のフォントサイズが、IEの表示フォントに連動して変化するのを抑止すること。
副効果としてサイト別のユーザースクリプトも可能になっている。
/*
* Using domain specific "user style sheet" in Internet Explorer.
* This is the way of set font-size to user's choice and enable
* [Ctrl] + [MouseWheel] zooming in compiled html help file(.chm).
* Still more effect, this enables tiny user scripts in Internet
* Explorer(but not compatible Grease Monkey).
*/
HTML {
behavior:expression( (function(el){
var cssfile;
var _doc = el.document;
var myFolder = 'file://C:/Documents and Settings/username/My Documents/CSS/';
var _href = _doc.location.href.toLowerCase();
if(_href.slice(0,13) == 'mk:@msitstore'){
/* stylesheet file for chm */
cssfile = 'chm.css';
} else {
switch(_doc.location.host.toLowerCase()){
/* */
case 'www.example.com':
cssfile = 'example.css';';
break;
case 'www2.example.com':
case 'www3.example.com':
cssfile = 'example2.css';';
break;
}
}
if(cssfile){
var elmLink = _doc.createElement('link');
elmLink.rel='stylesheet';
elmLink.type='text/css';
elmLink.href= myFolder + cssfile;
_doc.getElementsByTagName('head')[0].appendChild(elmLink);
}
el.runtimeStyle.behavior = 'none';
})(this));
}
javascript の case 文にはワイルドカードor正規表現が使えないので複数ドメインに同じ設定をする場合は、case文を続けて書く。





