尝试在iframe中使用Cordova插件

Mna*_*rro 13 html javascript iframe plugins cordova

我正在使用Cordova在iframe中加载HTML.一切正常,但我需要访问原始HTML中的插件.
原始代码是这样的

navigator.camera.getPicture(onSuccess, onFail);
Run Code Online (Sandbox Code Playgroud)

当我在iframe中加载HTML时,我需要这样做

parent.navigator.camera.getPicture(onSuccess, onFail);
Run Code Online (Sandbox Code Playgroud)

这段代码工作,但我真的需要不要更改原始代码.有人知道如何在iframe中使用cordova插件吗?

tnt*_*rox 3

将 cordova.js 链接添加到要加载到 ifame 中的 html 文件。

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
Run Code Online (Sandbox Code Playgroud)