99 lines
No EOL
2.4 KiB
HTML
99 lines
No EOL
2.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Test Webview Window</title>
|
|
|
|
<script type="application/javascript">
|
|
|
|
function readCookie() {
|
|
document.getElementById("cookie_text").innerText = document.cookie;
|
|
}
|
|
|
|
function postSimpleMessage() {
|
|
if (window.webkit) {
|
|
window.webkit.messageHandlers.test.postMessage("Hello");
|
|
}
|
|
}
|
|
|
|
function postMapMessage() {
|
|
if (window.webkit) {
|
|
window.webkit.messageHandlers.test.postMessage({"key1": 0, "key2": "value"});
|
|
}
|
|
}
|
|
|
|
function promptMessage() {
|
|
let result = prompt("test", "hello");
|
|
document.getElementById("prompt_result").innerText = result;
|
|
}
|
|
|
|
function updateCookie() {
|
|
document.cookie = "username=test; date=2021"
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
|
<body>
|
|
|
|
Hello World!
|
|
|
|
<p id="context">
|
|
|
|
</p>
|
|
|
|
<br/>
|
|
<button type="button" onclick="postSimpleMessage()">PostSimpleMessage</button>
|
|
<button type="button" onclick="postMapMessage()">PostMapMessage</button>
|
|
|
|
<br/>
|
|
<button type="button" onclick="promptMessage()">PromptMessage</button>
|
|
<p id="prompt_result">
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<button type="button" onclick="updateCookie()">updateCookie</button>
|
|
<p id="cookie_text"></p>
|
|
|
|
<br>
|
|
<p id="user_agent_text"></p>
|
|
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
function getMixinContext() {
|
|
let ctx = {};
|
|
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.MixinContext) {
|
|
ctx = JSON.parse(prompt('MixinContext.getContext()'))
|
|
ctx.platform = ctx.platform || 'iOS'
|
|
} else if (window.MixinContext && (typeof window.MixinContext.getContext === 'function')) {
|
|
ctx = JSON.parse(window.MixinContext.getContext())
|
|
ctx.platform = ctx.platform || 'Android'
|
|
}
|
|
return ctx
|
|
}
|
|
|
|
let context = getMixinContext();
|
|
|
|
var e = window.document.getElementById("context");
|
|
if (context === undefined) {
|
|
e.innerText = "context not defined";
|
|
} else {
|
|
e.innerText = JSON.stringify(context);
|
|
}
|
|
|
|
</script>
|
|
|
|
<script type="application/javascript">
|
|
// document.getElementById("prompt_result").innerText = prompt("init");
|
|
readCookie()
|
|
|
|
document.getElementById("user_agent_text").innerText = navigator.userAgent;
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html> |