2012-12-27 25 views
1

我正在運行一個泡菜。當我通過iOS 6中查看移動Safari瀏覽器中我的web應用程序,我能夠成功地打開了,當應用程序通過獨立打開的所有鏈接將退出應用程序的我的基本目標鏈接的<a href="link.html" target="mainframe"到我的回顧性的iframe <iframe src="http://www.linkexample.org/" name="mainframe"></iframe>鏈接將無法在iOS獨立的web應用程序中的iframe目標中打開

雖然並進入Mobile Safari。你可以在http://lacitilop.com/m2

看到一個工作示例任何人有任何建議如何解決這個問題?

回答

1

您需要編寫一些javascript來更改iframe的SRC。

一開始,讓您的應用工作,這樣的鏈接將不能使用類似下面的(順便說一下它的使用jQuery)打開Safari瀏覽器:

if (window.navigator.standalone) { 

$(document).on(
    "click", 
    "a", 
    function (event) { 

     event.preventDefault(); 

     var aurl = $(event.target).attr("href"); 
     if (aurl) { 
      location.href = $(event.target).attr("href"); 
     } 
     else { 
      location.href = this; 
     } 
    } 
); 

}

,那麼你就需要修改它以與iframe一起工作。

更多的iPhone應用程序的東西,你會想看看這個:

http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html

+0

感謝拉克蘭!這就是我想到的,但不知道如何繼續。我將如何配置iframe部分?例如' $(文件)。在( 「點擊」, 「主機」, 功能(事件){ event.preventDefault(); 變種aurl = $(event.target).attr(的 「href」 ); 如果(aurl){ location.href = $(event.target).attr(的 「href」);} 其他 { location.href =此; } } );」 ?或者我錯過了什麼? – Laxiton6893

+0

有點難以破譯你的代碼,我已經在我的網站上提供了一個示例:http://metaltheater.com/test.html,這工作在我的iphone :) – Rocklan

+0

哦哇。這是一個簡單的修復。謝謝! – Laxiton6893

相關問題