当站点重定向时,phonegap设备准备好不会被触发

时间:2014-10-07 09:46:44

标签: cordova

我需要你的帮助,对于以下情况,

我要将移动网站转换为移动应用,所以我决定使用phonegap。

from index.html i redirect to the mobile site domain using  meta tag
Ex: <META HTTP-EQUIV="refresh" CONTENT='2;URL=http://m.test.com/testApp.jsp'>

它工作正常。但我需要做一些额外的功能,如追踪按钮,通知,联系人列表,这就是为什么我需要设备就绪功能,而不是在上述场景中触发

请向我提供任何建议,例如我如何从服务器端jsp或任何新想法调用设备就绪功能。

下面是我的例子。

    <!DOCTYPE html>
     <html>
      <head>
               <META HTTP-EQUIV="refresh" CONTENT='2;URL=http://m.test.com/testApp.jsp'>
               <script src="js/cordova-2.7.0.js" type="text/javascript" charset="utf-8"></script>
      <script type="text/javascript" charset="utf-8">
      document.addEventListener("deviceready", onDeviceReady, false);

      function onDeviceReady()
      {
         alert("test");
      }

      </script>

</head>

1 个答案:

答案 0 :(得分:0)

忘记元标记。将您的代码放在onDeviceReady函数中:

function onDeviceReady()
      {
         //alert("test");
         document.location = "http://m.test.com/testApp.jsp";
      }

但也许你的方法不是最好的,Single Page Application

更好