简体   繁体   中英

How to prevent links in iOS webapp from opening in a new Safari-tab

I'm creating an html application for iPads. I add the webapp to the homescreen using the "favorite" option. However, after I do this, every (internal) URL opens in a new safari tab. How do I prevent this? At the moment it is impossible to use my navigation which directs to other html files.

I aready found this code. Hower i get an error "undefined" on every url.

$( document ).on( "click", "a", function( event ){   
    page.event.preventDefault();   
    time.location.href = $( event.target ).attr( "href" );
});

You are using a page and time variables, which don't seem to be defined anywhere.

$(document).on('click', 'a', function(e) {
    e.preventDefault();
    document.location.href = $(this).attr('href');
});

As simple as that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM