Skip to content

Instantly share code, notes, and snippets.

@minsOne
Last active May 6, 2024 15:11
Show Gist options
  • Save minsOne/c45f71e1ae8076a9f85325d7dd0f1e07 to your computer and use it in GitHub Desktop.
Save minsOne/c45f71e1ae8076a9f85325d7dd0f1e07 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>iOS 웹뷰 호출</title>
<style>
/* 버튼을 화면 가운데 정렬하고 적당한 크기로 설정하기 위한 CSS */
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 50px 75px; /* 버튼의 안쪽 여백 설정 */
font-size: 30px; /* 버튼의 폰트 크기 설정 */
}
</style>
</head>
<body>
<button onclick="openiOSWebView()" class="centered">iOS 웹뷰 열기</button>
<script>
function openiOSWebView() {
window.webkit.messageHandlers.actionHandler.postMessage({
"action": "hello",
"message": "Hello from JavaScript!"
});
}
// javaScriptFunction 함수 정의
function javaScriptFunction() {
window.webkit.messageHandlers.actionHandler.postMessage({
"action": "log",
"message": "called javaScriptFunction function"
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment