api.execScript的使用
在城市UICityList中选择城市返回获取城市内容的操作(我是从a.html点击后进入城市选择的界面b.html,当我选中时返回a.html,并赋值给控件选中的城市内容,新手,求解!!!!
)
a.html点击进入b.html界面如下:
function city() {
api.openWin({
name : 'city',
url : '../../html/detailframes/b.html'
});
}
//获取城市(b.html中)
- var currCity = $api.getStorage('myCityName');
- var iaf = api.require('UICityList');
- iaf.open({
- x: 0,
- y: pos.h,
- width: api.frameWidth,
- height: api.frameHeight - pos.h,
- resource: 'widget://json/UICityList.json',
- currentCity: currCity,
- locationWay: 'WiFi',
- hotTitle: '热门城市',
- placeholder: '输入城市名或首字母查询'
- },function(ret,err) {
- var cityInfo = ret.cityInfo;
- //通知main.html页面重新设置城市名称
- if(cityInfo) {
- api.execScript({
- name: 'a',//name 指的是窗口名,不是窗口的文件名,请问您的窗口名是 homeFixed 吗?
- frameName: 'b',//frame1 是子窗口名,不是子窗口的html文件名,请问您的子窗口是 frame1吗?
- script: 'setCityName("'+ cityInfo.city +'",true)'
- });
- }
- api.closeWin();
- });
- }
- api.execScript({
- name: 'a',//name 指的是窗口名,不是窗口的文件名,请问您的窗口名是 homeFixed 吗?
- frameName: 'b',//frame1 是子窗口名,不是子窗口的html文件名,请问您的子窗口是 frame1吗?
- script: 'setCityName("'+ cityInfo.city +'",true)'
- });
- a指的是winname,如果是index,就写root,b是a里面的一个frame,填写你打开b的时候,open frame中填写的name名称

浙公网安备 33010602011771号