Skip to content

Instantly share code, notes, and snippets.

@JillevdW
Last active February 23, 2018 11:05
Show Gist options
  • Save JillevdW/b2befcffa67eb713bcc62fd9d028b4c3 to your computer and use it in GitHub Desktop.
Save JillevdW/b2befcffa67eb713bcc62fd9d028b4c3 to your computer and use it in GitHub Desktop.
webview medium javascript
function addPerson(name, age) {
//It's really this simple. We'll call this from the native code.
console.log('Name: ' + name + ' Age: ' + age);
}
function sendNameToNative(name) {
//This function will send the name to native.
//We can add an EventListener to an object on the page to call this function when it is clicked.
try {
webkit.messageHandlers.callback.postMessage(name);
} catch(err) {
console.log('Can not reach native code');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment