This repository has been archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
How to Overwrite links in a WebView
Camilo edited this page Jul 27, 2020
·
1 revision
If you have a $webcontainer
agent in your app. You can listen
to a href
links and execute different native behaviours depending
on the url provided.
In the following example (created by user RAPOS
) we can make
a link url to trigger a phone call if the url contains tel
prefix.
Otherwise the ahref
will follow the normal behaviour.
With this method we can trigger any native functionality available.
It is also configured the background
color to be white,
and the progress
bar to be transparent.
{
"$jason": {
"head": {
"title": "Overwriting ahref behaviour",
"actions": {
"ahref_handler": [{
"{{#if $jason.url.indexOf('tel') !== -1 }}": {
"type": "$href",
"options": {
"view": "app",
"url": "{{$jason.url}}"
}
}
}, {
"{{#else}}": {
"type": "$default"
}
}]
}
},
"body": {
"background": {
"type": "html",
"text": "<html><body><h1><a href='tel:987654321'>Call ME</a></h1></body></html>",
"action": {
"trigger": "ahref_handler"
},
"style": {
"background": "#ffffff",
"progress": "rgba(0,0,0,0)"
}
}
}
}
}
- Telegram: https://t.me/jasonelle
- Website: https://jasonelle.com
- Additional: https://jasonelle-archive.github.io/docs/legacy/