Re: Creating a home screen "web app" for smart phone
| From: | mbox at s22 dot us | Date: | Sat, 25 Apr 2020 19:26:50 +0000 |
| Subject: | Re: Creating a home screen "web app" for smart phone | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-327110@lists.php.net to get a copy of this message | ||
Thanks for all the responses. I was hoping to stay away from JavaScript or a framework for this,
as it’s just a simple script for myself. I’ll look into REST and Ember for future use, but for
now I found a super simple fix.
I used a little JavaScript snippet for all the links and that makes the entire script usable as a
PWA. As an example, I replaced links like:
<a class="nav-link" href="<?php echo 'purchases.php?'.$params
?>">Purchases</a>
with:
<a class="nav-link" href="javascript:
ahref_go(\'purchases.php?'.$params.'\');">Purchases</a>
<script>
function ahref_go(url) {
window.location.assign(url);
}
</script>
This allows multiple pages to work as a single Add To Homescreen web app on the iPhone. It works
the same as a full <a href> page refresh, but it prevents Mobile Safari from jumping out of
full-screen mode.
Thanks again,
Frank