입력폼안에 원하는 글자를 계속 반전 시키며 디스플레이합니다.
| Script Example |
<html> <head><title>폼안
글자 반전</title> <script language="JavaScript">
<!--- var CurrentMsg
= 'hello '; function
update(msg) {
var pad_str="";
n = msg.length;
if(n<72) { pad
= (73-n)/2; for(var
i=0; i<pad; i++) {
pad_str+=" "; }
}
CurrentMsg = pad_str + msg;
document.messages.field.value = CurrentMsg;
clearTimeout(timer);
timer = setTimeout("idleMsg()",2000);
} function
MakeArray(n) {
this.length=n;
for(var i = 1; i<= n; i++) {
this[i] = "";
}
return(this); }
var index = 1;
var
notice_num = 4; var
notices = new MakeArray(notice_num);
notices[1]
= "안녕하세요.";
notices[2] = "홈페이지
바이블입니다.";
notices[3] = "많은 도움이
되기를 바랍니다.";
notices[4] = "감사합니다";
var timer = setTimeout('idleMsg()',0);
function
nochange() {
document.messages.field.value = CurrentMsg;
} function
idleMsg() {
update(notices[index++]);
if(index>notice_num) {
index=1;
} }
// --> </script> </head>
<body> <center>
<form name="messages" method="get" onsubmit="return
false"> <input type="text" name="field"
size="55" onchange="nochange()"
onfocus="self.status='this is a javascript
info. field'; return true"> </form>
</center> </body>
</html> |
|
|
| 설명 |
| 파란색 부분에서 원하는 글자를 입력하세요. 멧세지를 더 늘리고 싶으시면
빨간색부분에 총 멧세지를 지정하고 파란색 부분에서 추가되는 내용을 더 적으시면
됩니다. |
|
|
|
|