2012-04-10 2 views
0

Iphone/Android 스토어의 Phonegap에 포장하는 jquery 모바일 앱이 있습니다. PhoneGap없이 예상 한 것처럼 작동하는 iframe을 사용하는 페이지가 하나 있습니다. 그러나 일단 래핑 된 Iframe은 실제로 앱이 새 창/브라우저를 열고 앱을 종료합니다. 해결 방법이 있는지 아는 사람 있습니까? 감사합니다.Iframe이 한 번 감겨 진 새 창에서 열립니다. Phonegap

+0

사실 나는 이것이 Android에서 문제라는 것을 알고 있습니다. 또한 역사가 처리되는 방식에 내부적 인 변화가있을 때까지 수정이 가능할 지 확신 할 수 없습니다. –

+0

이것은 android의 버그입니다. http://code.google.com/p/android/issues/detail?id=17535 해결 방법 찾기 ... – user1496391

답변

1

http://denrobapps.com/2010/12/phonegap-and-iframes/

첫째, 개방 PhoneGapDelegate.m이 코드 블록 찾기 :

- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 
{ 
NSURL *url = [request URL]; 

/* 
* Get Command and Options From URL 
* We are looking for URLS that match gap://<Class>.<command>/[<arguments>][?<dictionary>] 
* We have to strip off the leading slash for the options. 
*/ 
if ([[url scheme] isEqualToString:@"gap"]) { 

    InvokedUrlCommand* iuc = [[InvokedUrlCommand newFromUrl:url] autorelease]; 

    // Tell the JS code that we've gotten this command, and we're ready for another 
    [theWebView stringByEvaluatingJavaScriptFromString:@"PhoneGap.queue.ready = true;"]; 

    // Check to see if we are provided a class:method style command. 
    [self execute:iuc]; 

    return NO; 
} 

/* 
* If a URL is being loaded that's a local file URL, just load it internally 
*/ 
else if ([url isFileURL]) 
{ 
    //NSLog(@"File URL %@", [url description]); 
    return YES; 
} 

/* 
* We don't have a PhoneGap or local file request, load it in the main Safari browser. 
*/ 
else 
{ 
    //NSLog(@"Unknown URL %@", [url description]); 
    //[[UIApplication sharedApplication] openURL:url]; 
    return NO; 
} 

return YES; 
} 

삽입이 다른-경우 오른쪽 첫번째 아래 경우 그 블록의 문 :

else if ([[url scheme] isEqualToString:@"http"]) 
{ 
    return YES; 
} 

또한 [[UIApplication sharedApplication] openURL : url]이 마지막 else 문에서 주석 처리되지 않았는지 확인하십시오. 그렇지 않으면 iFrame에서 링크를 클릭해도 작동하지 않습니다.

else 
{ 
    //NSLog(@"Unknown URL %@", [url description]); 
    [[UIApplication sharedApplication] openURL:url]; 
    return NO; 
} 
+0

감사합니다. – 29er

0

이는 phonegap이 기본적으로 외부 콘텐츠를 사용 중지하고 내장 브라우저를 참조하기 때문입니다.

<access origin="http://127.0.0.1*"/> <!-- allow local pages --> 
<!-- <access origin="https://example.com" /> allow any secure requests to example.com --> 
<!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www --> 
<!-- <access origin=".*"/> Allow all domains, suggested development use only --> 

을 나는 문서를 추측 :이 라인을 찾아 다음 텍스트 편집기 오픈>과 -

당신은 파일 /res/xml/cordova.xml에

오른쪽 클릭을이 문제를 해결할 수 있습니다 거기에 대해 스스로 말하고 있습니다. 몇 가지 액세스 기원 (동일한 서버에 모든 코드를 호스트 함)을 허용하고 초기 파일을 가리키는 것에 대해서도 알지 못합니다. 그래서 나는 더 이상 사용/자산/www를 사용하지 않습니다.

관련 문제