我在配置文件中设置:
<access origin="*" subdomains="true" />
<access origin=".*" subdomains="true" />
<content src="http://mydomain.pl/aps_mobile/" />
但是在 http://mydomain.pl/aps_mobile/不执行事件“deviceready”并且 navigator.camera 未定义。 我做错了什么?
最佳答案
如果从外部主机执行cordova脚本,您将无法访问硬件资源,因为该脚本未映射到Phonegap应用程序的libs/cordova.x.x.x.jar。 但你可以这样解决:
在 res/xml/config.xml 中
<access origin="*" />
<content src="index.html" />
在 Assets /www/index.html
<body>
<script type="text/javascript" src="cordova-x.x.x.js"></script>
<iframe name="framewrap" id="framewrap"
style="border:0;position: absolute; top: 0; left: 0;width: 100%;"
src="http://yourwebsite.pl">
</iframe>
<script type="text/javascript">
document.getElementById("framewrap").contentWindow.navigator = navigator;
</script>
</body>
最后,在相机配置中,如果您想要 DATA_URL,则必须将destinationType 设置为 0;如果您想要 FILE_URI,则必须将destinationType 设置为 1;如果您想要 NATIVE_URI,则必须将destinationType 设置为 2。
希望对你有帮助
关于android - Phonegap - 从外部网站访问 api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16064142/