스크립트에 랜덤 처리 후 랜덤값에 따라 iframe 호출하려는데~~ 초보라서 채택완료
자바 스크립트에서 아래와 같이 랜덤값에 따라 alert 하는것은 확인했구요
Alert 대신 iframe으로 호출하려는데,,,에러나는데
A CASE
B CASE
C CASE
var sec = Math.floor(Math.random() * 10000 + 10000) ;
setTimeout("document.location.reload()", sec);
if (sec > 30000 ){
alert("A CASE" + sec);
} else if ( sec > 20000) {
alert("B CASE" + sec);
} else if ( sec > 10000) {
alert("C CASE" + sec);
} else {
alert("D CASE" + sec);
}
답변 1개
올려주신 랜덤 alert 소스를 랜덤 document.write 소스로 변경 해주시면 됩니다.
아래와 같이 해주세요.
var sec = Math.floor(Math.random() * 40000 + 10000) ;
setTimeout("document.location.reload()", sec);
if (sec > 30000 ){
document.write("A CASE" + sec + "");
} else if ( sec > 20000) {
document.write("B CASE" + sec + "");
} else if ( sec > 10000) {
document.write("C CASE" + sec + "");
} else {
document.write("D CASE" + sec + "");
}
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인