λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
πŸ’š 개발/μ•ˆλ“œλ‘œμ΄λ“œ

[μ•ˆλ“œλ‘œμ΄λ“œ] μ›Ήλ·° 디버깅 μ‰½κ²Œ ν•˜λŠ” 방법 - Chrome inspect μ‚¬μš©λ²• (2)

by devshin.kr 2021. 5. 2.
728x90

index.html 을 μƒμ„±ν•˜λ©΄ κΈ°λ³Έ μ½”λ“œλŠ” μ•„λž˜μ™€ 같이 λ˜μ–΄ μžˆλ‹€.
여기에 μƒˆλ‘œμš΄ μ½”λ“œλ₯Ό μΆ”κ°€ν•΄ 보자.

<!DOCTYPE html>
<html>
    <head>
        <meta charset="EUC-KR">
        <title>Insert title here</title>
    </head>
    <body></body>
</html>



ν…ŒμŠ€νŠΈ μ½”λ“œ

<!DOCTYPE html>
<html>
    <head>
        <meta charset="EUC-KR">
        <title>Insert title here</title>
    </head>
    <body>
        <script>
            function button1() {
                alert('test');
            }
        </script>
        <button onclick='button1();'>ν…ŒμŠ€νŠΈ λ²„νŠΌ</button>
    </body>
</html>

<script>function button1() {alert('test');}</script> λ₯Ό <body></body> μ•ˆμ— μΆ”κ°€ν•˜κ³ ,
</script> λ°–, </body> μ•ˆμ—μ„œ <button onclick='button1();'>ν…ŒμŠ€νŠΈ λ²„νŠΌ</button> 을 μΆ”κ°€ν–ˆλ‹€.



index.html λ§Œμ„ μž‘μ„±ν–ˆμ„ λ•Œμ˜ κ²°κ³Ό ν™”λ©΄



λΉ¨κ°„μƒ‰μœΌλ‘œ μΉ ν•œ 뢀뢄은 본인의 아이피이닀.
μžμ‹ μ˜ 아이피λ₯Ό λͺ¨λ₯Έλ‹€λ©΄ ν‚€λ³΄λ“œμ—μ„œ
μœˆλ„μš°+R ν‚€ > cmd > ipconfig λͺ…λ Ήμ–΄λ‘œ μ‘°νšŒν•  수 μžˆλ‹€.




...
이제 Android μ›Ήλ·°λ₯Ό λ§Œλ“€κΈ° μœ„ν•œ μž‘μ—…μ„ μ‹œμž‘ν•΄ 보자.

index.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="EUC-KR">
        <title>Insert title here</title>
    </head>
    <body>
        <script type="text/javascript" charset="utf-8" src="test.js"></script>
        <script>
            // μ•ˆλ“œλ‘œμ΄λ“œμ— helloAndroid λΌλŠ” λ¬Έμžμ—΄μ„ 전달
            function button1() {
                test.callAndroid(callS, callF, "helloAndroid");
            }
            
            // callback ν•¨μˆ˜. 성곡
            function callS(result) {
                console.log("성곡 : " + result);
            }
            
            // callback ν•¨μˆ˜. μ‹€νŒ¨
            function callF(result) {
                console.log("μ‹€νŒ¨ : " + result);
            }
        </script>
        <button onclick='button1();'>ν…ŒμŠ€νŠΈ λ²„νŠΌ</button>
    </body>
</html>



test.js

var test = {
    callAndroid: function (callbackSuccess, callbackFail, sInput) {
        var result = window.BRIDGE.androidFunc(sInput);
        if (result !== null) 
            callbackSuccess(result);
         else 
            callbackFail(result);
        
    }
};





... μ•ˆλ“œλ‘œμ΄λ“œ μ½”λ“œλŠ” λ‹€μŒ μž₯에...

λ‹€μŒ
[μ•ˆλ“œλ‘œμ΄λ“œ] μ›Ήλ·° 디버깅 μ‰½κ²Œ ν•˜λŠ” 방법 - Chrome inspect μ‚¬μš©λ²• (3)

 

[μ•ˆλ“œλ‘œμ΄λ“œ] μ›Ήλ·° 디버깅 μ‰½κ²Œ ν•˜λŠ” 방법 - Chrome inspect μ‚¬μš©λ²• (3)

μ•ˆλ“œλ‘œμ΄λ“œ μƒ˜ν”Œ μ½”λ“œλ₯Ό μž‘μ„±ν•΄ 보겠닀. activity_main.xml <?xml version="1.0" encoding="utf-8"?> AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> MainActivity.java package com.example.webvie..

devshin93.tistory.com

 

λŒ“κΈ€