카테고리 없음

JS 브라우저 정보 객체

Canyi 2022. 10. 20. 11:33

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>브라우저 객체</title>
</head>
<body>
    <script>
        document.write('<h1>' + location.protocol + '</h1><br/>');
        document.write('<h1>' + location.host + '</h1><br/>');
        document.write('<h1>' + location.hostname + '</h1><br/>');
        document.write('<h1>' + location.href + '</h1><br/>');
        document.write('<h1>' + location.pathname + '</h1><br/>');
        document.write('<h1>' + location.port + '</h1><br/>');
    </script>
    </script>
</body>
</html>

BitNami 배포경로

https://piaocanyi.tistory.com/222

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>브라우저 객체</title>
</head>
<body onload="myLoad()">
    <script>

        // document.write('<h1>' + location.protocol + '</h1><br/>');
        // document.write('<h1>' + location.host + '</h1><br/>');
        // document.write('<h1>' + location.hostname + '</h1><br/>');
        // document.write('<h1>' + location.href + '</h1><br/>');
        // document.write('<h1>' + location.pathname + '</h1><br/>');
        // document.write('<h1>' + location.port + '</h1><br/>');
       
        
        //경로 확인 및 주소 이동
        function myLoad() {
            var LocationProp = location.href;
            document.getElementById('result').innerHTML = '현재 URL은' + LocationProp + '입니다.';
        }

        function changeAddr() {
            location.href = "https://www.google.com";
        }
    </script>
    
    <button onclick="changeAddr()">주소 변경</button>
    <h1><div id="result"></div></h1> 

	//현재시간 refresh/문서이동
    <!-- <script>
        var currentTime = new Date();
        document.write("<h1> 현재시간은 " + currentTime.toLocaleTimeString() + "입니다. </h1><p>" )
        function updateDoc() {
            location.reload();
        }
        function moveDoc() {
            location.replace("객체.html");
        }

    </script>

    <button onclick="updateDoc()">새로고침</button>
    <button onclick="moveDoc()">문서이동</button> -->
</body>
</html>