屏幕调整大小后重新加载iframe

时间:2017-07-19 15:19:51

标签: jquery html iframe

我有一个加载内容的iframe,并在内容加载后动态调整自身大小,以匹配内容的高度。我正在使用此代码来调整iframe的大小,它位于文档就绪部分

class ViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate{

@IBOutlet var l: UILabel!
@IBOutlet var pl: UIPickerView!
@IBOutlet var l2: UILabel!
@IBOutlet var pl2: UIPickerView!

override func viewDidLoad() {
    super.viewDidLoad()
    pl.dataSource = self
    pl.delegate = self
    pl2.dataSource = self
    pl2.delegate = self
}

let choices = ["1","2","3","4","5","6","7","8","9","10","11"]

func numberOfComponents(in pickerView: UIPickerView) -> Int {
    return 1
}

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
    if pickerView == pl1 {
        return choices[row]
    } else if pickerView == pl2 {
        return choices2[row] //or whatever you want to use as the dataSource for pl2
    } else {
        return nil
    }
}

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
    //do the same as above
    return choices.count
}

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    //do the same as above
    l.text = choices[row]
}

}

我的问题是iframe似乎在窗口调整大小时重新加载,这当然是清除输入到窗体中的任何表单数据。我没有使用任何jquery来检查正在调整大小的浏览器窗口,也没有运行任何刷新内部页面的jquery。所以我不确定这是iframe问题还是jquery问题。我的iframe看起来像这样......

var frame = $('#formFrame', window.parent.document);
var height = $('#main').height();
frame.height(height + 40);
frame.width("720");

我在下面的iframe中没有应用CSS是我的主要部门的CSS,jquery用来基于iframe的大小。

<iframe id="formFrame" width="720" height="240" frameborder="0" scrolling="no" src="http://www.ncat.edu/caes/comm-form-system/index.html"></iframe>

0 个答案:

没有答案