PhoneGap-----event in the Code

<!DOCTYPE html>
<html>
<head>
<title>PhoneGap Event Example</title>

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
   document.addEventListener("deviceready",onDeviceReady,false);
   
   function onDeviceReady(){
	   //To detect when the device is ready, use the  deviceready event.
	   document.addEventListener("pause",onPause,false);
	   document.addEventListener("resume",onResume,false);
	   document.addEventListener("backbutton",onBackButton,false);
	   document.addEventListener("menubutton",onMenuButton,false);
	   document.addEventListener("searchbutton",onSearchButton,false);
	   document.addEventListener("online",isOnline,false);
	   document.addEventListener("offline",isOffline,false);
   }
   
   function onPause(){
	   //To detect when the application has been paused, use the  pause event.
   }
   
   function onResume(){
	   //To detect when the application has been resumed, use the resume event.
   }
   
   function onBackButton()
   {
	   //To detect when the Back button has been pressed on an Android device,use the backbutton event.
	   alert("onBackButton!");
   }
   
   function onMenuButton(){
	   //To detect when the Menu button has been pressed on an Android device,use the menubutton event.
	   alert("onMenuButton");
   }
   
   function onSearchButton(){
	   //To detect when the Search button has been pressed on an Android device, use the searchbutton event.
   }
   
   function isOnline(){
	   //To detect when the application is online (connected to the Internet), use the online event.
   }
   
   function isOffline(){
	   //To detect when the application is ol  ine (not connected to the Internet),use the offline event.
   }
   
</script>
</head>
<body>
  <h1>PhoneGap Event Example</h1>
</body>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章