user2232273
user2232273

Reputation: 4964

a href open page in the same window

When i open my project in safari browser and i add the icon on my homescreen of my ipad the links doesn´t work how i want.

the situation is this:

i have a directory project/index.html .

and i have the directory project/edition/edition.html (this open in a popup window in the index.html)

and the directory project/magazine/magazine.html

when i click on the button in the index.html to open the popup window to select the menu i want when the user select some option go to magazine.html. and the problem is that open always in the browser and i want that continue in my app without close the app.

any idea?

i use for this the ` and i have tested with all target: self, parent, top etc.. and always open in the browser

the code:

index.html

<div data-role="popup" id="edicaorevista" style="max-height:100%">
    <a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a>
        <iframe src="Edition/Edition.html" style="width:730px;height:300px"></iframe>
  </div>

 <a href="#edicaorevista" id="ler" data-rel="popup" data-inline="true" data-direction="reverse" data-position-to="window"></a>

edition.html

<a href="../magazine/magazine.html"><img src="imgs/landscape/edicao2013.png" alt="image01" />

Upvotes: 1

Views: 13641

Answers (1)

user2232273
user2232273

Reputation: 4964

i solved it..

i have implement a script in the .. that allows me when i see my app in fullscreen mode, what i mean is when i add the icon to the home screen and open it.. the links dont open anymore in the browser.

the script i use is this:

 (function(document,navigator,standalone) {
            // prevents links from apps from oppening in mobile safari
            // this javascript must be the first script in your <head>
            if ((standalone in navigator) && navigator[standalone]) {
                var curnode, location=document.location, stop=/^(a|html)$/i;
                document.addEventListener('click', function(e) {
                    curnode=e.target;
                    while (!(stop).test(curnode.nodeName)) {
                        curnode=curnode.parentNode;
                    }
                    // Condidions to do this only on links to your own app
                    // if you want all links, use if('href' in curnode) instead.
                    if('href' in curnode && ( curnode.href.indexOf('http') || ~curnode.href.indexOf(location.host) ) ) {
                        e.preventDefault();
                        location.href = curnode.href;
                    }
                },false);
            }
        })(document,window.navigator,'standalone');

Upvotes: 1

Related Questions