1
아래 지정된 코드 이외의 html 문자열에 동적 텍스트를 삽입하는 더 좋은 방법이 있습니까?문자열 내에서 javascript 함수 실행
var code = 'siteCode1'; 문자열로
HTML 코드 :
는existing: '<p>Log in with your'+ eval("siteVarObj('+code+').siteName") +'account</p>',
function siteVarObj(siteCode){
if(siteCode === 'siteCode1'){
this.siteName = 'google.com';
this.siteContactUsURL = '';
}else if(siteCode === 'siteCode2'){
this.siteName = 'stackoverflow.com';
this.siteContactUsURL = '';
}
return this;
}
'eval' ==='evil' –