{
if (typeof window.my_iframe == "undefined") {
window.my_iframe = document.getElementById(frameId)
if (typeof window.my_iframe == "undefined")
throw "fatal: iframe object not found"
}
return window.my_iframe
}
function getFrameWin()
{
var f = getFrame()
var win = f.contentWindow || f.contentDocument
return win
}
function getFrameDoc()
{
var win = getFrameWin()
return win.contentDocument || win.document
}
var doc = getFrameDoc()
doc.body.getElementById('div1').style.display = 'block'
问的不太清楚,你是想问cordova.js怎么和java进行通信吗?
java端你可以web.xml定义个httpservlet
<servlet><servlet-name>RequestSend</servlet-name>
<servlet-class>com.RequestSend</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RequestSend</servlet-name>
<url-pattern>/servlet/RequestSend</url-pattern>
</servlet-mapping>
然后在RequestSend类中
public class RequestSend extends HttpServlet {public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
。。。。。业务处理
return "jsonpCallback(json返回结果)"
}
}
然后在页面层不知道你用的什么框架,如果是jquery就可以直接
$.ajax({type : "get",
async:false,
url : “..../servlet/RequestSend?参数”,
dataType : "jsonp",
jsonp: "callbackparam",//服务端用于接收callback调用的function名的参数
jsonpCallback:"jsonpCallback",//callback的function名称
success : function(json){
},
error:function(data){
}
})
onic基本能满足组件需求,用cordova那么界面部分就都交给html,业务部分才用android,否则你要移植到ios时又要写一套,那你还不如直接用android原生开发,运行效率快很多