임호준

0413자바스크립트 실습

function message(){
document.write("????");
var d = new Date(300000000);
document.getElementById("demo").innerHTML = d;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>js</title>
<script type="text/javascript" src = "hello.js"></script>
</head>
<body onload="message()" >
<script type="text/javascript">
</script>
<p>hi <hr></p>
<p id="demo">
</p>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<meta charset="utf-8">
<body>
<button onclick="myFunction()">Try it</button>
<button onclick="myFunction2()">try it </button>
<button onclick="myFunction3()">사진 띄우기 </button>
<button onclick="myFunction4()">네이버로가기 </button>
<div id="id">
안녕하십니까
</div>
<div id="id2">
안녕하세영
</div>
<script>
function myFunction() {
var mywindow = window.open("", "_self", "width=500,height = 300");
mywindow.document.write("<h1>Hello</h1>");
}
function myFunction2() {
var x = document.getElementById("id");
x.innerHTML = "changed";
}
function myFunction3() {
var x = document.getElementById("id2");
x.innerHTML = "<img src=../punch.gif>"; //src 뒤에 "" 가 오면 이 코드는 ""<img src = .."까지 밖에 인식하지못해 error발생함
}
function myFunction4(){
location.assign("http://www.naver.com");
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>123</title>
</head>
<body>
<button type="button" onclick = "myFunction()" name="button">click this</button>
<div id="div1">
<h1>안녕하세요</h1>
</div>
<input type="text" name="" value="" id="input1">
<button type="button" onclick="myFunction2()" name="button">click this</button>
<div id="div2">
</div>
<script type="text/javascript">
"use strict";
function myFunction(){
var name = prompt("Enter your Name", "Name");
var t = document.getElementById("div1");
t.innerHTML = "<h1>"+name+"</h1>";
}
function myFunction2(){
var name = document.getElementById("input1").value;
var div = document.getElementById("div2");
div.innerHTML = "<h1>"+name+"</h1>";
}
</script>
</body>
</html>