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) (0) | 2021.05.02 |
---|---|
[μλλ‘μ΄λ] net::ERR_CACHE_MISS (0) | 2021.05.02 |
[μλλ‘μ΄λ] PrettyFormatStrategy μ¬μ©ν΄μ μ 리λ λ‘κ·Έ μΆλ ₯νλ λ°©λ² (0) | 2021.04.28 |
[μλλ‘μ΄λ] SDK, JDK, NDK (0) | 2021.04.15 |
[μλλ‘μ΄λ] Switch λ²νΌ μ¬μ©λ² (0) | 2021.03.22 |
λκΈ