Home > Web Front-end > JS Tutorial > body text

Detailed explanation of the iframe content becoming blank after the keyboard pops up on the WeChat page

小云云
Release: 2018-02-07 13:45:27
Original
1921 people have browsed it

This article mainly shares with you the detailed explanation of the iframe content becoming blank after the keyboard pops up on the WeChat page. When the keyboard pops up, the footer is also pushed up; and when the search is completed (to refresh the entire page), after the keyboard retracts, the keyboard in the iframe When the place where you live turns white. How to solve this problem? Hope this article can help everyone.

Foreword:

Because the iframe needs to be adapted, so, the height needs to be calculated


//整体高
var win = $(window).height();
//搜索栏
var header = $('header').height();
//导航栏
var nav = $('.navpwrap').height();
//页底
var footer = $('footer').height();
//iframe
$('#main').height(win -header + nav - footer);
Copy after login

Solution:

Cause:

When the keyboard is put down, This is caused by the height of the iframe not being reset again.

Option ①: Put the height of the first iframe in the cookie

Note: In Xiaomi 6, 'win' seems to conflict, so change it to 'win1'


//导入
<script src="jquery.cookie.js"></script>
var win = $(window).height();
//获取cookie里
var winCookie = $.cookie("win1",{path: &#39;/&#39; });
//若cookie里无,则填充;若cookie里有,则取出
if(!winCookie){
 $.cookie("win1", win,{path: &#39;/&#39; });
}else{
 win = winCookie;
}
Copy after login

Related recommendations:

JavaScript print iframe content sample code_javascript skills

The above is the detailed content of Detailed explanation of the iframe content becoming blank after the keyboard pops up on the WeChat page. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template