Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 带有Phonegap的选项卡栏无法在每一页上工作_Javascript_Ios_Cordova - Fatal编程技术网

Javascript 带有Phonegap的选项卡栏无法在每一页上工作

Javascript 带有Phonegap的选项卡栏无法在每一页上工作,javascript,ios,cordova,Javascript,Ios,Cordova,我正在使用带有NativeControl/TabBar插件的PhoneGap,它正在为第一页工作。然而,当我按下导航到另一个页面时,插件就不再有效了 在index.html页面上: 按下任何按钮都会转到相应的HTML页面,并选择正确的选项卡。但是,在此页面上,没有任何选项卡继续工作-按tab按钮只会高亮显示它,但不会将视图重新定位到页面 我曾尝试将同一脚本粘贴到其他页面的页眉上,但也没有结果。我以前使用的解决方案是通过AJAX加载所有内容,而不是加载其他.html页面。我在下面包含了一些片段:

我正在使用带有NativeControl/TabBar插件的PhoneGap,它正在为第一页工作。然而,当我按下导航到另一个页面时,插件就不再有效了

在index.html页面上:

按下任何按钮都会转到相应的HTML页面,并选择正确的选项卡。但是,在此页面上,没有任何选项卡继续工作-按tab按钮只会高亮显示它,但不会将视图重新定位到页面


我曾尝试将同一脚本粘贴到其他页面的页眉上,但也没有结果。

我以前使用的解决方案是通过AJAX加载所有内容,而不是加载其他.html页面。我在下面包含了一些片段:

在index.html中,我指定了一个DIV来接收每个页面的html

<div id="ajaxCont"> </div>
然后,可以按如下方式创建每个选项卡项:

tabBar.createItem("contact", "Contact", "/www/img/734-chat.png", {
    onSelect: function() {
       loadPage("contact.html", null, null, "Contact");
    }
});

我很想知道这个问题的答案!
function loadPage(url, onleave, onenter, title) {                               

   // If onleave function specified
   if (onleave) {
      onleave();
   }

   var xmlhttp = new XMLHttpRequest();

   // Callback function when XMLHttpRequest is ready
   xmlhttp.onreadystatechange=function(){
      if(xmlhttp.readyState == 4){
         if (xmlhttp.status == 200 || xmlhttp.status == 0) {
            document.getElementById('ajaxCont').innerHTML = xmlhttp.responseText;

            // If onenter function specified
            if (onenter) {
                onenter();
            }
         }else {
            document.getElementById('ajaxCont').innerHTML = "Error loading page " + url;
         }
      }
   };

   xmlhttp.open("GET", url , true);
   xmlhttp.send();
}
tabBar.createItem("contact", "Contact", "/www/img/734-chat.png", {
    onSelect: function() {
       loadPage("contact.html", null, null, "Contact");
    }
});