<!DOCTYPE html PUBLIC "-//W3C//DTD Xhtml 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title></title>

<style>

body {

font-size: 9pt;

}


#panel {

width: 600px;

height: 300px;

border: 1px solid #999;

position: relative;

}


#bar {

position: absolute;

left: 50px;

top: 190px;

width: 500px;

height: 20px;

background: #F30;

}


#img1 {

position: absolute;

left: 50px;

top: 70px;

}


#nav {

text-align: center;

width: 600px;

}

</style>


<script>

window.onload=function(){

this.initEventListener();

}

function initEventListener(){

var img1 = document.getElementById('img1');

var nowLeft = img1.offsetLeft; //초기 이미지 위치

var endLeft;

var moveLeft = 0; //움직이는 동안의 이미지 위치

var speed = 2; //속도

var chk=0; //앞으로 갈지, 뒤로 갈지 체크하는 변수

var goTimer; //setInterval을 정지시키기 위해서 사용하는 변수 


var btnStart = document.getElementById("btn_start").addEventListener("click",function(){

start();

},false);

var btnStop = document.getElementById("btn_stop").addEventListener("click",function(){

clearInterval(goTimer);

},false);

function start(){

//clearInterval을 사용하기 위해서 goTimer가 setInterval을 참조한다.

//참조하는 동시에 setInterval(moveImg, 10) 실행!!!

goTimer = setInterval(moveImg, 10);

}

function moveImg(){

if(chk == 0){ // chk가 0이면 앞으로 += 하며 출발!!!

nowLeft += speed; //속도인 speed를 2로 지정했었지요...

moveLeft = nowLeft + "px";

if(nowLeft > 430){ //좌표 430까지 가면 chk=1로 하여 뒤로 돌아가기 위한 조건을 준다.

chk = 1;

}

}

if(chk == 1){ // chk가 1이면 뒤로 -= 하며 출발!!!

nowLeft -= speed; //뒤로 -하며 돌아가겠지요?

moveLeft = nowLeft + "px";

if(nowLeft == 50){ //첫 위치인 50에 도착하면 chk=0 으로 하여 앞으로 가기 위한 조건을 준다.

chk = 0;

}

}

img1.style.left = moveLeft;

}

}

</script>

</head>


<body>

<div>

<h4>#img1을 #bar의 영역에서 계속 좌우로 움직이도록 만들어주세요.</h4>

<div id="panel">

<div id="bar"></div>

<div id="img1">

<img src="images/img1.jpg">

</div>

</div>

<div id="nav">

<button id="btn_start">시작</button>

<button id="btn_stop">멈춤</button>

</div>

</div>

</body>

</html>



 

 

 

 

이미지 캡쳐하기 귀찮아서 재활용한 프로폼트 화면...

 

뭇튼 숫자를 프로폼트로 받는다..... 그후 수정은 안됨...

 

사실 귀찮아서 더이상 수정안함.... 뭐 간단한 소스이니 자체적으로 수정할수 있을겁니다.

 

<script language="javascript">
var cnt = 0;
var i;
var j;

 


i = eval(prompt("첫번째 숫자입력1",""));
j = eval(prompt("두번째 숫자입력2",""));

 


/*
function input(x){
 if(cnt == 0){
  i = x;
  cnt = 1;
  form1.text1.value = i;
 } else {
  j = x;
  cnt = 0;
  form1.text1.value = i + j;
 }
}
*/


function plus(){
 total = eval(i+ "+" +j);
 form1.text1.value = i + "+" + j + "=" + total;
 alert(i + "+" + j + "=" + total);
 document.bgColor="red";
}

function minus(){
 total = eval(i+ "-" +j);
  form1.text1.value = i + "-" + j + "=" + total;
 alert(i + "-" + j + "=" + total);
  document.bgColor="blue";
}

function div(){
 total = eval(i+ "/" +j);
  form1.text1.value = i + "/" + j + "=" + total;
 alert(i + "/" + j + "=" + total);
  document.bgColor="black";
}

function muti(){
 total = eval(i+ "*" +j);
  form1.text1.value = i + "*" + j + "=" + total;
 alert(i + "*" + j + "=" + total);
  document.bgColor="yellow";
}

 

</script>
</head>
<body>
<form name="form1">
  <input type="button"  value="0" onclick="input('0')" />
  <input type="button"  value="1" onclick="input('1')" />
  <input type="button"  value="2" onclick="input('2')" />
  <input type="button"  value="3" onclick="input('3')" />
  <input type="button"  value="4" onclick="input('4')" />
  <br>
  <input type="button"  value="5" onclick="input('5')" />
  <input type="button"  value="6" onclick="input('6')" />
  <input type="button"  value="7" onclick="input('7')" />
  <input type="button"  value="8" onclick="input('8')" />
  <input type="button"  value="9" onclick="input('9')" />
  <p>
    <input type="text" name="text1"  value="" />
  <p>
    <input type="button" value="덧셈" onclick="plus()" />
    <input type="button"  value="뺄셈" onclick="minus()" />
    <input type="button"  value="나눗셈" onclick="div()" />
    <input type="button"  value="곱셈" onclick="muti()" />
</form>
</body>
</html>

 

 

 

 

 

 

num1 = eval(prompt("구구단 숫자입력1",""));
num2 = eval(prompt("구구단 숫자입력2",""));
renum = num1;
var str = "구구단 표\n";

for(a=1; a<10; a++){
 while(num1<=num2){
  count = num1 * a;
  str +=  num1 + "*" + a + "=" ;
  if(count < 10)
  str +=   " " ;
  str += count + "   ";
  num1++;
 }
 num1= renum
 str += "\n";
}

alert(str);

 

--------------------------------------

 

다음은 세로로 출력하는 코드

 

 start=prompt("몇단 부터 시작하시겠습니다??","");

 end=prompt("몇단 까지 출력하시겠습니다??","");


 var string = "";

 for(i=start; i<=end; i++) {
  
  for(j=1; j<=9; j++) {
   
   string += "  " + start + " X " + j + "=" + start*j + "\n";
  }
  string +="\n\n";
   start++;
  if(start>end)
  break;
     document.write("<br>");
 }
 alert(string) ;

 

 

 

for문의 a++이 작동이 안되서 내가 야매?로 num1++;를 추가한것 같다.....

 

수업시간에 했던것인데 일단 출력물은 잘 나왔기 때문에 패스.....

 

 

혹 이 블로그를 보고 온 사람이 있다면 ㅇㅇ대생일지도 ㅎㅎㅎ

//단축키
var key = new Array();


// 여기부터 수정하세요. 필요한 갯수만큼 여려 라인을 넣으시면 됩니다.
// key['단축키'] = "이동할 페이지 주소"
key['h'] = "http://fs1025.mireene.com/index.html";
key['1'] = "http://fs1025.mireene.com/menu01/page1.html";
key['2'] = "http://fs1025.mireene.com/menu02/page1.html";
key['3'] = "http://fs1025.mireene.com/menu03/page1.html";
key['4'] = "http://fs1025.mireene.com/menu04/page1.html";
key['5'] = "http://fs1025.mireene.com/menu05/page1.html";


function getKey(keyStroke) {
if ((event.srcElement.tagName != 'INPUT') && (event.srcElement.tagName != 'TEXTAREA')){
isNetscape=(document.layers);
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
for (var i in key)
if (which == i) window.location = key[i];
}
}
document.onkeypress = getKey;

 

//달력 시작
function setStyle(id,style,value)
{
    id.style[style] = value;
}

function calendar()
{
        var date = new Date();
        var day = date.getDate();
        var month = date.getMonth();
        var year = date.getYear();
        if(year<=200)
        {
                year += 1900;
        }
        months = new Array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12');
        days_in_month = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
        if(year%4 == 0 && year!=1900)
        {
                days_in_month[1]=29;
        }
        total = days_in_month[month];
        var date_today = year+'년'+months[month]+'월 '+day+'일';
        beg_j = date;
        beg_j.setDate(1);
        if(beg_j.getDate()==2)
        {
                beg_j=setDate(0);
        }
        beg_j = beg_j.getDay();
        document.write('<table class="cal_calendar" onload="<tbody id="cal_body"><tr><th colspan="7">'+date_today+'</th></tr>');
        document.write('<tr class="cal_d_weeks"><th>일</th><th>월</th><th>화</th><th>수</th><th>목</th><th>금</th><th>토</th></tr><tr>');
        week = 0;
        for(i=1;i<=beg_j;i++)
        {
                document.write('<td class="cal_days_bef_aft">'+(days_in_month[month-1]-beg_j+i)+'</td>');
                week++;
        }
        for(i=1;i<=total;i++)
        {
                if(week==0)
                {
                        document.write('<tr>');
                }
                if(day==i)
                {
                        document.write('<td class="cal_today" style="background-color:#e0e0e0;">'+i+'</td>');
                }
                else
                {
                        document.write('<td>'+i+'</td>');
                }
                week++;
                if(week==7)
                {
                        document.write('</tr>');
                        week=0;
                }
        }
        for(i=1;week!=0;i++)
        {
                document.write('<td class="cal_days_bef_aft">'+i+'</td>');
                week++;
                if(week==7)
                {
                        document.write('</tr>');
                        week=0;
                }
        }
        document.write('</tbody></table>');
      
        return true;
}
//달력 끝

 

//스네이크 텍스트
var x,y;
var step=10;
var flag=0;
var message="I LOVE DOKDO";
message=message.split("");
var xpos=new Array()
for(i=0; i<message.length-1; i++){
 xpos[i] = -50;
}

var ypos=new Array()
for(i=0; i<message.length-1; i++){
 ypos[i] = -50;
}

function handlerMM(e){
 x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX;
 y = (document.layers) ? e.pageY : document.body.scrollLeft+event.clientY; 
 flag = 1;
}

function makesnake(){
 if(flag ==1 && document.all){
  for(i=message.length-1; i>=1; i--){
   xpos[i]=xpos[i-1]+step;
   ypos[i]=ypos[i-1];
  }
  xpos[0]=x+step;
  ypos[0]=y;
  
  for(i=0; i<message.length-1; i++){
   var thisspan = eval("span"+(i)+".style")
   thisspan.posLeft=xpos[i];
   thisspan.posTop=ypos[i];
  }
 }
 else if(flag ==1 && document.layers){
  for(i=message.length-1; i>=1; i--){
   xpos[i]=xpos[i-1]+step;
   ypos[i]=ypos[i-1];
  }
  xpos[0]=x+step;
  ypos[0]=y;
  for(i=0; i<message.length-1; i++){
   var thisspan = eval("document.span"+i)
   thisspan.left=xpos[i];
   thisspan.top=ypos[i];
  }
 }
 
 var timer=setTimeout("makesnake()", 30)
}

 

 

 

 

사용하고자 하는 html 파일에다가

 

<body onLoad="makesnake();" style="overflow:hidden;">

 

 

<!-- 스네이크 텍스트 -->
<script language="javascript">
for(i=0; i<=message.length-1; i++){
 document.write("<span id='span" + i + "' class='spanstyle'>")
 document.write(message[i])
 document.write("</span>")
}

if(document.layers){
 document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM
</script>

//즐겨찾기
function addbookmark() {
 var url = "http://www.fs1025.mireene.com";   // URL
 var title = "I love Dokdo";           // 사이트 이름
 var browser=navigator.userAgent.toLowerCase();
  
 // Mozilla, Firefox, Netscape
 if (window.sidebar) {
  window.sidebar.addPanel(title, url,"");
 }
 // IE or chrome
 else if( window.external) {
  // IE
  if (browser.indexOf('chrome')==-1){
   window.external.AddFavorite( url, title);
  } else {
  // chrome
   alert('CTRL+D');
  }
 }
 // Opera - automatically adds to sidebar if rel=sidebar in the tag
 else if(window.opera && window.print) {
  return true;
 }
 // Konqueror
 else if (browser.indexOf('konqueror')!=-1) {
  alert('CTRL+B');
 }
 // safari
 else if (browser.indexOf('webkit')!=-1){
  alert('CTRL+D');
 } else {
  alert('With this button, you will not be able to add your favorites.')
 }
}

 

// 타이틀
document.title=' I LOVE DOKDO ';

+ Recent posts