2016-10-16 13:29:14 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Messaging Test</title>
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
|
|
<meta name="viewport" content="width=320, user-scalable=no">
|
|
|
|
</head>
|
|
|
|
<body>
|
2018-01-13 06:03:51 +00:00
|
|
|
<p>Messages received from React Native: 0</p>
|
2016-10-16 13:29:14 +00:00
|
|
|
<p>(No messages)</p>
|
|
|
|
<button type="button">
|
|
|
|
Send message to React Native
|
|
|
|
</button>
|
|
|
|
</body>
|
|
|
|
<script>
|
|
|
|
var messagesReceivedFromReactNative = 0;
|
|
|
|
document.addEventListener('message', function(e) {
|
|
|
|
messagesReceivedFromReactNative += 1;
|
|
|
|
document.getElementsByTagName('p')[0].innerHTML =
|
2018-01-13 06:03:51 +00:00
|
|
|
'Messages received from React Native: ' + messagesReceivedFromReactNative;
|
2016-10-16 13:29:14 +00:00
|
|
|
document.getElementsByTagName('p')[1].innerHTML = e.data;
|
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementsByTagName('button')[0].addEventListener('click', function() {
|
|
|
|
window.postMessage('"Hello" from the web view');
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</html>
|