如何将Phonegap Inapp浏览器内容保存到父应用程序以供脱机查看

问题描述:

我正在构建一个使用inapp浏览器从网站上在线绘制内容的PGB的phonegap项目,我想要抓取一些加载的内容在inapp浏览器中保存,供用户在应用程序中离线访问。 我已经设法发布数据到网站并得到一个响应,但我不能保存数据的应用程序。如何将Phonegap Inapp浏览器内容保存到父应用程序以供脱机查看

function loadStopCallBack3() { 

if (inAppBrowserRef != undefined) { 

    inAppBrowserRef.insertCSS({ code: " .highlight{background-color: yellow !important;}" }); 

    var options = { 
     retrieveLocId : 'FAOR FACT', 

    }; 
    var script2='$("#IAgree").dialog(\'close\');var form = document.createElement("form");form.setAttribute("action","https://www.notams.faa.gov/dinsQueryWeb/queryRetrievalMapAction.do");'; 
    script2+='form.setAttribute(\'method\',"post");'; 
    script2+='var hiddenField = document.createElement("input");hiddenField.setAttribute("type", "text");hiddenField.setAttribute("name", "retrieveLocId");hiddenField.setAttribute("value", "FAOR");form.appendChild(hiddenField);'; 
    script2+=' hiddenField = document.createElement("input");hiddenField.setAttribute("type", "text");hiddenField.setAttribute("name", "reportType");hiddenField.setAttribute("value", "Report");form.appendChild(hiddenField);'; 
    script2+=' hiddenField = document.createElement("input");hiddenField.setAttribute("type", "text");hiddenField.setAttribute("name", "actionType");hiddenField.setAttribute("value", "notamRetrievalByICAOs");form.appendChild(hiddenField);'; 
    script2+='form.submit();'; 

    inAppBrowserRef.executeScript(
    { code : script2}, 
     function(returnval){ 
     console.log("----------------->"+returnval);         
     } 

    ); 

    inAppBrowserRef.show(); 
} 
} 

根据数据的大小以及使用的类型,你可以简单地将数据存储在localstorageweb sql.

两者在HTML5和PhoneGap的应用程序支持,并且可以离线访问。