Editor.OpenFile()のポリフィル

提供:MeryWiki
ナビゲーションに移動 検索に移動

Editor.OpenFile()は開いたDocumentオブジェクトを返さないので、Documentオブジェクトを返すようにするポリフィルです。Editor.OpenFile()が開いたDocumentオブジェクトを返すようになるまでは使えます。

function OpenFile(file, encoding, flags){
    var i, j, e, d;
    file = new ActiveXObject("Scripting.FileSystemObject").GetAbsolutePathName(file);
    window.Editor.OpenFile(file, encoding, flags);
    for(i = 0; i < window.Editors.Count; i++){
        e = window.Editors.Item(i);
        for(j = 0; j < e.Documents.Count; j++){
            d = e.Documents.Item(j);
            if(d.FullName){
                if(d.FullName === file){
                    return d;
                }
            }
        }
    }
}
スポンサーリンク