function replace_title(title){ if(document.title){ var tmp_str = document.title.split(' - ')[0]; } else { var tmp_str = ''; } document.title = tmp_str+' - '+title; } function replace_by_id(id, value){ if (value) { document.getElementById(id).innerHTML = value; }else{ document.getElementById(id).innerHTML = ''; } } replace_by_id('domain_id', '23.cn');