Im在Cordova構建應用程序,每次點擊<a href="">
時,它都會在本機瀏覽器(我的iPhone上的Safari)中打開。Cordova在每個鏈接中打開原生瀏覽器
例, 我試圖打開perfil.html,科爾多瓦被打開: https://var/containers/Bundle/Application/51F56BF8-8BD1-44AE-8157-D9242801E4D3/HelloCordova.app/www/perfil.html 在Safari上。
Im在Cordova構建應用程序,每次點擊<a href="">
時,它都會在本機瀏覽器(我的iPhone上的Safari)中打開。Cordova在每個鏈接中打開原生瀏覽器
例, 我試圖打開perfil.html,科爾多瓦被打開: https://var/containers/Bundle/Application/51F56BF8-8BD1-44AE-8157-D9242801E4D3/HelloCordova.app/www/perfil.html 在Safari上。
記住將每個鏈接轉換爲javascript'location.href'。
如果您有jQuery的(好老朋友;)),你正在使用的錨絕對鏈接,你可以用:
$(document).on("click","a[href]", function(e){
e.stopPropagation();
window.location.href = $(this).attr("href");
});
這將設置此beavior所有的鏈接...
固定。
以下代碼是存在於與重定向用戶的向右協議目標(http或SSL)應用:
if (document.URL.indexOf('http://') === -1 && document.URL.indexOf('https://') === -1) {
// PhoneGap application
} else {
if (location.protocol != 'https:') {location.href = 'https:' + window.location.href.substring(window.location.protocol.length);}
}
:
if (location.protocol != 'https:') {location.href = 'https:' + window.location.href.substring(window.location.protocol.length);}
替換爲