|
本帖最后由 ACFans51 于 2015-6-4 16:12 编辑
看论坛里有人说在服务器上的HTML里执行API不行,呐什么,刚好弄了这么一个代码,直接撸上来
演示功能:web.html通过openFrame加载远程页面target.html,服务端页面target.html标题自动覆盖到APP内的标题栏处(不是系统的状态栏)
APP内:
web.html 内写好的函数setTitle(),这个web.html 的窗口名称是 web- /*
- * 设置页面标题
- */
- function setTitle(str,openStatus){
- $api.html($api.byId('pageName'),str); // 未检查数据安全性,未过滤特殊字符,注意XSS
- }
复制代码
服务器上:
target.html 内把这代码放在页面最后面- apiready = function(){
- api.execScript({
- name: 'web',
- script: 'setTitle("我是新标题");'
- });
- };
复制代码
其他功能要使用的话也是类似的实现方法,具体 JS 代码写 APP 内,服务器端页面通过 execScript 去调 APP 内的函数执行就行啦~~~注意传参后的数据安全过滤
|
|