2012-12-28 3 views
0

경고 상자, 스플래시 화면처럼 phonegap에서 함수를 실행하는 데 문제가 있습니다. 그래서 어떤 해결책이 있다면 알려주세요. 하나의 코드 (index.html)는 경고창 적용을 위해 아래에 주어집니다.Phone Gap에 클래스를로드 할 수 없습니다.

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Notification Example</title> 

    <script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script> 
    <script type="text/javascript" charset="utf-8"> 

    // Wait for Cordova to load 
    // 
    document.addEventListener("deviceready", onDeviceReady, false); 

    // Cordova is ready 
    // 
    function onDeviceReady() { 
     // Empty 
    } 

    // alert dialog dismissed 
    function alertDismissed() { 
     // do something 
    } 

    // Show a custom alertDismissed 
    // 
    function showAlert() { 
     navigator.notification.alert(
      'You are the winner!', // message 
      alertDismissed,   // callback 
      'Game Over',   // title 
      'Done'     // buttonName 
     ); 
    } 

    </script> 
    </head> 
    <body> 
    <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p> 
    </body> 
</html> 

나는 값진 솔루션을 기대합니다.

감사합니다.

+2

당신은 스택 트레이스가 있습니까? – asgoth

+2

당신의 문제는 정확히 무엇입니까? – Gajotres

+0

Gajotres : Phonegap (index.html)의 코드를 시뮬레이트하고 싶습니다. 그러나 그것은 클래스를로드 할 수 없다는 것을 보여줍니다. 그래서 내가 뭘 할 수 있는지 말해줘? – user1934206

답변

0

deviceready 함수에서 phonegap 함수를 래핑해야합니다.

알림 예

<script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script> 
    <script type="text/javascript" charset="utf-8"> 

    // Wait for Cordova to load 
    // 
    document.addEventListener("deviceready", onDeviceReady, false); 

    // Cordova is ready 
    // 
    function onDeviceReady() { 
     // Show a custom alertDismissed 
    // 
    function showAlert() { 
     navigator.notification.alert(
      'You are the winner!', // message 
      alertDismissed,   // callback 
      'Game Over',   // title 
      'Done'     // buttonName 
     ); 
    } 
    } 

    // alert dialog dismissed 
    function alertDismissed() { 
     // do something 
    } 



    </script> 
    </head> 
    <body> 
    <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p> 
    </body> 
</html> 
관련 문제