18 Star 51 Fork 15

HENG CHENGFEI/SwiftJS

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
h5.html 723 Bytes
一键复制 编辑 原始数据 按行查看 历史
HENG CHENGFEI 提交于 2016-02-01 15:25 +08:00 . update
<html>
<head>
<meta charset="UTF-8">
<title>H5页面</title>
</head>
<body>
<h1 align="center">标题1(APP调用JS,使标题变成红色)</h1>
<script>
// JS调用APP(callbackHandler:要两边一致)
function callNativeApp () {
try {
webkit.messageHandlers.callbackHandler.postMessage("I Love you");
} catch(err) {
console.log('The native context does not exist yet');
}
}
// APP调用JS
function redHeader() {
document.querySelector('h1').style.color = "red";
}
</script>
<button style="text-align:center;height:50px;width:200px;font-size:30px;" onclick="callNativeApp()">调用APP</button>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Swift
1
https://gitee.com/chengfeisoft/SwiftJS.git
git@gitee.com:chengfeisoft/SwiftJS.git
chengfeisoft
SwiftJS
SwiftJS
master

搜索帮助