Created
May 29, 2019 05:45
-
-
Save nakamuuu/72f818e1e413088e5564d3f03cc04ba7 to your computer and use it in GitHub Desktop.
openUrl JSブリッジテスト用ページ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<script> | |
var bridge; | |
document.addEventListener('WebViewJavascriptBridgeReady', function onBridgeReady(event) { | |
bridge = event.bridge; | |
bridge.init(function(message, responseCallback) {}); | |
}, false); | |
function runCallbackWithBridge(callback) { | |
if (bridge != null) { | |
callback(bridge); | |
} else { | |
document.addEventListener('WebViewJavascriptBridgeReady', function onBridgeReady(event) { | |
bridge = event.bridge; | |
bridge.init(function(message, responseCallback) {}); | |
callback(bridge); | |
}, false); | |
} | |
} | |
function openUrlForIos(url, title) { | |
runCallbackWithBridge(function(bridge) { | |
bridge.callHandler('openUrl', {'url': url}); | |
}); | |
} | |
function openUrlForAndroid(url, title) { | |
droid.openUrl(title, url); | |
} | |
</script> | |
</head> | |
<body> | |
<input type="button" value="openUrl (for iOS)" onclick="openUrlForIos('https://www.google.co.jp/', 'タイトル');"> | |
<input type="button" value="openUrl (for Android)" onclick="openUrlForAndroid('https://www.google.co.jp/', 'タイトル');"> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment