Aetrox's avatar

homescreen app

Hello,

I came to a problem where I can't find a solution to.

I try to make a website that needs to work on an iPad and on normal browsers.

On the iPad I save the website on the home screen as "app". Many years ago I found this little nice script, which tells the mobile browser to not open new links in browser and to stay in the nice app view on the iPad. (no url bar and so on...)

Worked until I wanted to integrate a vuetable 2 with pagination.

The vuetable works perfectly until I want to search through my pages on the table at the iPad. It refreshes the page and clears the filter. This little script blocks the functionality of the pagination:

<script>(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(d.href.indexOf("http")||~d.href.indexOf(e.host))&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone")</script>

Can someone explain me at least what the problem is, so I can explicitly search for a solution or does someone even know already what I can do to solve it?

Thanks in advance

best regards

Simon

0 likes
1 reply
Aetrox's avatar
Aetrox
OP
Best Answer
Level 1

Solution:

    <script type="text/javascript">
    if(("standalone" in window.navigator) && window.navigator.standalone){

// If you want to prevent remote links in standalone web apps opening Mobile Safari, change 'remotes' to true
var noddy, remotes = false;

document.addEventListener('click', function(event) {
    
    noddy = event.target;
    
    // Bubble up until we hit link or top HTML element. Warning: BODY element is not compulsory so better to stop on HTML
    while(noddy.nodeName !== "A" && noddy.nodeName !== "HTML") {
        noddy = noddy.parentNode;
    }
    
    if('href' in noddy && noddy.href.indexOf('http') !== -1 && (noddy.href.indexOf(document.location.host) !== -1 || remotes))
    {
        event.preventDefault();
        document.location.href = noddy.href;
    }

},false);

}

Please or to participate in this conversation.