1

プロジェクトを Safari ブラウザーで開き、iPad のホーム画面にアイコンを追加すると、リンクが思いどおりに機能しません。

状況は次のとおりです。

ディレクトリ project/index.html があります。

そして私はディレクトリproject/edition/edition.htmlを持っています(これはindex.htmlのポップアップウィンドウで開きます)

およびディレクトリ project/magazine/magazine.html

index.html のボタンをクリックしてポップアップ ウィンドウを開き、必要なメニューを選択すると、ユーザーがいくつかのオプションを選択すると、magazine.html に移動します。問題は、ブラウザで常に開くことであり、アプリを閉じずにアプリで続行したいです。

何か案が?

私はこれに`を使用し、すべてのターゲットでテストしました:self、parent、topなど..そして常にブラウザーで開きます

コード:

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" />
4

2 に答える 2

1

私はそれを解決しました..

私は..にスクリプトを実装しました。これにより、アプリをフルスクリーンモードで表示したときに、ホーム画面にアイコンを追加して開くことができます..ブラウザでリンクが開かなくなりました。

私が使用するスクリプトはこれです:

 (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');
于 2013-06-06T21:57:33.983 に答える