Nacky(Issei Ishii)がDJ/Composerのようなふりして書き散らすblogサイト
Nacky - Snowland.net - blogを移転しました
2007-01-05
<select id="hoge"></select>としておいて
Element.update('hoge','<option value="1">one</option>');としても,IEはselectやtextareaに対してinnerHTMLが利かない.
if($(element).tagName.toLowerCase()=='textarea'){#書式・作法的にアレなのは勘弁
element.value = html.stripScripts();
}else if($(element).tagName.toLowerCase()=='select'){
var attrs=['name','size','id','multiple','onFocus','onBlur','onChange'];
var attrstr='';
for(i=0; i<attrs.length; i++){
var val=$(element).getAttribute(attrs[i]);
if(val=='null' || val=='' || val=='false' || val==null || val==false) continue;
if(typeof val=='function'){
val=val.toString();
val=val.substring(val.indexOf('{')+1,val.lastIndexOf('}')-1);
}
attrstr+=' '+attrs[i]+'="'+val+'"';
}
$(element).outerHTML = '<select'+attrstr+'>'+html.stripScripts()+'</select>';
}else{
element.innerHTML = html.stripScripts();
}
いずれにしろoptionとテーブル系のタグをIEでAjax.Updaterで呼ぶは鬼門w