IE6でposition:fixedをやりたい

画面右下にとあるナビゲーション要素を常に表示させたい時、IE7FirefoxOperaだと「position:fixed」で固定できるけど、IE6だと「position:fixed」というプロパティは無いのでどうしようと悩んでました。

.navi {
  position: fixed !important;
  position: absolute;
}

としてabsolute指定してもスクロールすると結局ずれるしダメだー。


調べてみると、IEではCSSにexpressionというJavaScriptを使って記述できるということが分かった。
なので、IE6でそれを使って位置を計算して表示すればいい。

<link rel="stylesheet" type="text/css" href="style.css" media="screen,tv,projection" />
<!--[if lt IE 7]> 
<style type="text/css">
   body {
     background: url(null) fixed;
   }
   .navi {
      position: absolute;
      top:expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ?  documentElement.scrollTop+document.documentElement.clientHeight-40 : document.body.scrollTop+document.body.clientHeight-40);
      right: 15px;
      z-index: 2000;
   }
</style>

という具合にIE6以下とそれ以外のブラウザでスタイルシートを分けるようにしてexpression使ったら上手くいきました。
「body{background: url(null) fixed;}」としているのは画面をスクロールする際に固定させたい要素がガタつくのを防ぐためです。
とりあえず「z-index:2000」くらいやっとけば前に表示されるべ!という適当さですけど・・・

[software]萌ディタjscript.javascript.txtに補完単語を追加

とりあえず補完する単語だけ追加。
直前の単語を判断して次の単語を絞り込むようにもしてみたけど何か遅いのと単語によってバラつきがでてる・・ので削除。
正規表現もっと勉強しなければ。。。


単語追加したければコンストラクタに配列で登録する。

function class_js() {
	this.name = 'jscript';
	this.parent = 'srcfile';
	this.ext = '\\.(js|javascript\\.txt)$';
	
	this.keywords = new Array(
	    "XMLHttpRequest", "ActiveXObject", "abstract", "boolean", "break", "byte", "case", "catch", "char", "class",
	    "const", "continue", "debugger", "default", "delete", "do", "double ", "else", "enum", "export", "extends",
	    "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in ",
	    "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public",
	    "return", "short", "static", "super ", "switch", "synchronized", "this", "throw", "throws", "transient",
	    "true", "try", "typeof", "var", "void", "volatile", "while", "with"
	);
	
	this.nativeObjs = new Array(
	    'Object', 'Function', 'Array', 'String', 'Boolean', 'Number', 'Math', 'Date', 'RegExp', 'Error'
	);
	this.htmlDoms = new Array(
	    'document', 'anchor', 'area', 'base', 'body', 'document', 'event', 'form', 'frame', 'frameset', 'history',
	    'iframe', 'image', 'input', 'link', 'location', 'meta', 'navigator', 'object', 'option', 'screen', 'select',
	    'table', 'tableData', 'tableHeader', 'tableRow', 'textarea', 'window',
	    'aLink', 'background', 'gbColor', 'id', 'link', 'scrollLeft', 'scrollTop', 'text', 'vLink',
	    'anchors', 'applets', 'childNodes', 'embeds', 'forms', 'images', 'links', 'stylesheets',
	    'body', 'cookie', 'documentElement', 'domain', 'lastModified', 'referrer', 'title', 'URL',
	    'close', 'createAttribute', 'createElement', 'createTextNode', 'focus', 'getElementById',
	    'getElementsByName', 'getElementsByTagName', 'open', 'write', 'writeln',
		'onClick', 'onDblClick', 'onFocus', 'onKeyDown', 'onKeyPress', 'onKeyUp',
		'onMouseDown', 'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseUp', 'onResize'
	);
	this.properties = new Array(
	    'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'eval', 'Infinity',
	    'isFinite', 'isNaN', 'NaN', 'parseFloat', 'parseInt', 'undefined', 'escape', 'unescape'
    );
	this.xmlWords = new Array('<![CDATA[', ']]>',
	    'name', 'specified', 'value',
	    'attributes', 'childNodes', 'firstChild', 'lastChild', 'namespaceURI', 'nextSibling', 'nodeName',
	    'nodeType', 'nodeValue', 'ownerDocument', 'parentNode', 'prefix', 'previousSibling', 'tagName',
	    'appendChild', 'cloneNode', 'getAttribute', 'getAttributeNode', 'getElementsByTagName',
	    'hasChildNodes', 'insertBefore', 'normalize', 'removeAttribute', 'removeAttributeNode',
	    'removeChild', 'replaceChild', 'setAttribute', 'setAttributeNode'
	);

	this.arrayProp = new Array(
	    'index', 'input', 'length', 'concat', 'join', 'pop', 'push', 'reverse', 'shift', 'splice', 'sort',
	    'toSource', 'toString', 'unshift', 'valueOf', 'watch', 'unwatch'
	);
	this.functionProp = new Array(
	    'arguments', 'arguments.callee', 'arguments.caller', 'arguments.length', 'arity',
	    'apply', 'call', 'toSource', 'toString', 'valueOf'
	);
	this.objectProp = new Array(
	    'constructor', 'prototype', 'eval', 'toSource', 'toString', 'unwatch', 'watch', 'valueOf'
	);
	this.stringProp = new Array(
	    'anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'concat', 'fixed', 'fontcolor', 'fontsize',
	    'fromCharCode', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'match', 'replace', 'search',
	    'slice', 'small', 'split', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLowerCase', 'toSource',
	    'toString', 'toUpperCase', 'watch', 'unwatch'
	);
	
}

として色設定できるように、f.onInitPropに以下を追加。

lex.AddKeywords( 'keyword', '1/' + this.keywords.join(' ') + '/', 'exstyle:キーワード');
lex.AddKeywords( 'htmlDom', '1/' + this.htmlDoms.join(' ') + '/', 'exstyle:DOM');
lex.AddKeywords( 'XMLWord', '1/' + this.xmlWords.join(' ') + '/', 'exstyle:XMLキーワード');
lex.AddKeywords( 'native-objects', '1/' + this.nativeObjs.join(' ') + '/', 'exstyle:組込済みオブジェクト');
lex.AddKeywords( 'properties', '1/' + this.properties.join(' ') + '/', 'exstyle:デフォルトプロパティ');
lex.AddKeywords( 'Array', '1/' + this.arrayProp.join(' ') + '/', 'exstyle:キーワード-Array');
lex.AddKeywords( 'Object', '1/' + this.objectProp.join(' ') + '/', 'exstyle:キーワード-Object');
lex.AddKeywords( 'Function', '1/' + this.functionProp.join(' ') + '/', 'exstyle:キーワード-Function');
lex.AddKeywords( 'String', '1/' + this.stringProp.join(' ') + '/', 'exstyle:キーワード-String');

あとはCtrl-spaceで補完できるよう

f.onCompleteRequest = function (arg, classname, methodname) {
	App.CompletionList.Clear();

	if (!getLeftParagraph().match(/\.([_a-zA-Z][_a-zA-Z0-9]*)?$/)) {
		App.CompletionList.Add(
			'keyword',
			this.keywords.join('\n'));
		App.CompletionList.Add(
			'html-word',
			this.htmlDoms.join('\n'));
		App.CompletionList.Add(
			'std-object',
			this.nativeObjs.join('\n'));
		App.CompletionList.Add(
			'properties',
			this.properties.join('\n'));
		App.CompletionList.Add(
			'XML-word',
			this.xmlWords.join('\n'));
		App.CompletionList.Add(
			'Array-word',
			this.arrayProp.join('\n'));
		App.CompletionList.Add(
			'Object-word',
			this.objectProp.join('\n'));
		App.CompletionList.Add(
			'Function-word',
			this.functionProp.join('\n'));
		App.CompletionList.Add(
			'String-word',
			this.stringProp.join('\n'));
	}
	App.CompletionList.Add(
		'identifier',
		getDynCompletionCandidates(
			/'([^']|\\')*'|"([^"]|\\")*"/g,
			/[_a-zA-Z][_a-zA-Z0-9]*/g).join('\n'));

	App.CompletionList.Popup(
		App.Prop(this.name, 'completion-case-sensitive'));
};

と追加すればオーケー。