외부 링크에서 내 앱의 링크를 강제로 열려고합니다. jQuery 모바일 & Phonegap 빌드로 작업하고 있습니다.생성 된 링크가 브라우저에서 열리지 않습니다. - Phonegap build
내 앱에 생성 된 연락처 세부 정보가있는 페이지가 있습니다. 세부 사항 중에는 해당 웹 사이트 링크가 있습니다.
row+='<div class="accWWW"> <a href="http://'+ data[i].website +'" onclick="openGenerated(this); return false;">'+ data[i].website +'</a></div>';
본인의 코드에는 다음 두 가지 기능이 정의되어 있습니다.
//function which forces open in browser
function openBrowser(url){
if(device.platform === 'Android') {
navigator.app.loadUrl(url, {openExternal:true});
} else {
window.open(url, '_system');
}
}
//opens generated URL's
function openGenerated(obj){
var url = obj.getAttribute("href");
console.log(url);
openBrowser(url);
return false;
}
나는 또한 내 index.html을에 간단한 <div class="accWWW"> <a href="#" onclick="openBrowser('http://www.google.com');"> Google </a></div>
세트가
그래서 구글이 링크가 아이폰 OS에 완벽하게 열립니다 (아이폰 OS 내 가장 큰 문제이기 때문에 아직 안드로이드에서 테스트하지 않은 경우) , openGenerated 함수를 추가하지 않았다면 생성 된 링크는 아무 것도하지 않습니다. 이제 액션이 있지만 앱 내부에서 열립니다.
그 이유는 무엇입니까? 노트북에 검사 할 때
이 또한 내가 콘솔에서 이러한 오류를 얻을 (링크 내 개발 URL입니다) :
Uncaught ReferenceError: device is not defined *link*:277 // makes sense probably, because I am not using a mobile device
Uncaught SecurityError: Blocked a frame with origin "http://www.test.com" from accessing a frame with origin "*link*". Protocols, domains, and ports must match.// what is this?
내가 생각
은 어쩌면 액세스 문제입니다,하지만 난 내 설정에서 <access origin="*" browserOnly="true" />
추가 .xml이므로이 문제가 있어서는 안됩니다.
최신 수정 : Android에서 Google 링크가 작동하지 않으며 생성 된 앱이 앱 내부에서 열립니다 ... 분명히 device.platform은 항상 null이지만 기기 플러그인은 가능한 한 XML에 추가됩니다. 폰갭 빌드에서 플러그인의 목록을 참조하십시오
Installed Plugins
Apps will be built with the latest version of a plugin unless you lock the version in your config.xml (see below). -- Plugin installed as a dependency of another plugin
Third Party VERSION LATEST VERSION
com.phonegap.plugin.statusbar 1.1.0 1.1.0
PhoneGap Core
org.apache.cordova.device 0.2.8 0.2.8
org.apache.cordova.inappbrowser 0.3.3 0.3.3
LATER 편집 :
Device.platform가 작동하지 않는 것, 그래서에, VED의 제안을 추가 내 기능을 수정 :
기능 openBrowser (URL) iOS에서 {
if(navigator.app)
navigator.app.loadUrl(url, {openExternal:true});
else {
var ref = window.open(url, '_system', 'location=no');
ref.addEventListener('loadstart', function(event) {
});
ref.addEventListener('loadstop', function(event) {
console.log(event.type + ' - ' + event.url);
});
ref.addEventListener('exit', function(event) {
});
}
}
은 여전히 응용 프로그램 내에서 열립니다. Android의 경우 정상적으로 작동한다고 생각합니다.
InAppBrowser 플러그인을 설치하려면 먼저이 링크 코드를 따라야합니다. http://stackoverflow.com/questions/21729288/target-blank-not-working-in-iphone/21730396#21730396 – Ved
여전히 앱 내부에서 열립니다. 내 마지막 편집에서 내 기능이 지금과 같습니다. –
window.open (your_url, '_system'); – Ved