2012-03-16 25 views
0

基本上我使用PhoneGap的創建iPhone應用程序,我使用的是原生控制插件爲了整合本地的TabBar - 我已經得到了工作但我不確定如何使它如此當每個標籤欄項目被選中,將用戶轉發到一個鏈接 - 在這個應用程序的情況下,我打算給用戶發送到特定的DIV ID #element。我也嘗試使用了標籤欄項目的形象,但這個似乎沒有被工作要麼...與PhoneGap的插件鏈接的TabBar項目

我如何去這樣做,我到目前爲止的代碼如下。

       <script type="text/javascript" charset="utf-8"> 

           function onBodyLoad() 
           { 
            document.addEventListener("deviceready",onDeviceReady,false); 
           } 

           /* When this function is called, PhoneGap has been initialized and is ready to roll */ 
           function onDeviceReady() 
           { 

            // Initializating TabBar 
            nativeControls = window.plugins.nativeControls; 
            nativeControls.createTabBar(); 

            // Item 1 tab 
            nativeControls.createTabBarItem(
                    "item1", 
                    "Item1", 
                    "/themes/images/[email protected]", 
                    {"onSelect": function() { 
                    location.href = "#section1" 
                    }} 
                    ); 

            // Item 2 tab 
            nativeControls.createTabBarItem(
                    "item2", 
                    "Item2", 
                    "/themes/images/[email protected]", 
                    {"onSelect": function() { 
                    location.href = "#section2" 
                    }} 
                    ); 

            // Item 3 tab 
            nativeControls.createTabBarItem(
                    "item3", 
                    "Item3", 
                    "/themes/images/[email protected]", 
                    {"onSelect": function() { 
                    location.href = "#section3" 
                    }} 
                    ); 

            // Item 4 tab 
            nativeControls.createTabBarItem(
                    "item4", 
                    "Item4", 
                    "/themes/images/[email protected]", 
                    {"onSelect": function() { 
                    location.href = "#section4" 
                    }} 
                    ); 

            // Item 5 tab 
            nativeControls.createTabBarItem(
                    "item5", 
                    "Item5", 
                    "/themes/images/[email protected]", 
                    {"onSelect": function() { 
                    location.href = "#section5" 
                    }} 
                    ); 

            // Compile the TabBar 
            nativeControls.showTabBar(); 
            nativeControls.showTabBarItems("mechanics", "materials", "waves", "electricity", "light"); 
            nativeControls.selectTabBarItem("mechanics"); 
           } 

           </script> 

回答