変更時にコードが解析されない理由
var comments_switcher = (function(){
var switcher = null;
var show = 'Show comments';
var hide = 'Hide comments';
function init(){
if ( switcher == null ) switcher = document.getElementById("comments_switch");
}
function switched_on(){
return switcher.value == show;
}
return {
trigger : function(do_init){
if ( do_init ) init();
switcher.value = switched_on() ? hide : show;
}
}
})();
の中へ
var comments_switcher = (function(){
var switcher = null;
var show = 'Show comments';
var hide = 'Hide comments';
function init(){
if ( switcher == null ) switcher = document.getElementById("comments_switch");
}
return {
trigger : function(do_init){
if ( do_init ) init();
switcher.value = switched_on() ? hide : show;
},
switched_on : function(){
return switcher.value == show;
}
}
})();
の代わりに関数オブジェクトを指定すると、なぜxmlhttp.onreadystatechange
機能しないのfunction() {}
ですか?