버튼(새창만들기,사진띄우기,location.assign)연습.html 1008 Bytes
<!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>";
        }

        function myFunction4(){
          location.assign("http://www.naver.com");
        }
    </script>

</body>

</html>