An IFRAME-based mobile nesting

Source: Internet
Author: User

Requirements Description

Last week received a new project, the mobile side needs to do a bottom with five navigation, click on different navigation page body display different pages, two pages are done by themselves, while the other three pages refer to another three URLs, of which two URLs are internal items and the other one is external (involving cross-domain).

Problem

Consider repeatedly after the most time-saving cost is the use of IFRAME, although in mobile use, my heart is very rejected, but other programs under investigation are not quite in line with the status quo. Each click to load a new IFRAME, more lazy, so two new pages also made an IFRAME, in the process of doing the following problems, summed up here:
1. The embedded IFRAME page cannot scroll
The ontent of the 2.meta element is inconsistent, the external page uses width=device-width, and the reference to the width=640 of one of the pages, which results in the page rendering cannot be zoomed out full screen
3.ios under which one of the pages inexplicably expands
4.iframe page A tag's anchor point invalidation
5. When I click on a to load an IFRAME page, in the switch to B, this time the B page font inexplicably become larger
6. The navigation bar has a style requirements, the active icon is the red icon, the other state is gray. One of those needs is where to go when you return and return to where.
7. An IFRAME cannot be reloaded after an Android machine is returned

Resolves a statement embedded IFRAME page where 4 of them are internal, homologous, so most of the issues handled do not have cross-domain issues. 1. The embedded IFRAME page cannot scroll

Wrap a div in the outer layer of the IFRAME and set it as scrollable

<div style="webkit-overflow-scrolling: touch;overflow-y: scroll;">    <iframe></iframe></div>

And the default behavior of the browser is forbidden, or it will be similar to sliding to the bottom of the effect of the rebound to conflict

$('body').on('touchmove',function(e){    e.preventDefault();});
Ontent inconsistency of 2.meta elements

This is not a good way, iframe rendering meta is the default to go to the top of the meta, so his own internal meta is invalid, because the project belongs to their own department, have permission to modify the code, so finally I reset the page meta, rewrite the page style.

3.ios under which one of the pages inexplicably expands

After the investigation I found that for the title of this type of white-space:nowrap, and the IFRAME page with the Swiper set width of 100%, and the mobile side for the adaptive body is also set to 100% in this case, The page inside the IFRAME under iOS will expand.
My solution is that the original project page Html,body is still set to 100%, and when the initialization of JS to get the width of the screen and then set the body width.

4.iframe page A tag's anchor point invalidation

If the IFRAME does not involve cross-domain, the network has compatible code can be re-set a tag, cross-domain cannot solve, because the cross-domain situation, the external page is unable to get to the element under the IFRAME, and finally this navigation made an external jump.

5.iframe page switch, the style of the page after the change of the inexplicable become large

Before I do the page switch, is used to not reload the IFRAME, but directly modify the URL of the IFRAME, but it seems that in this case, the previous page loading of the CSS is not completely erased, so the CSS is confusing. So the last time you switch, the soy milk iframe to remove, the append load new iframe.

6. After clicking on the page, the returned status tag

Used Localstorage to record url,navindex.

7. An IFRAME cannot be reloaded after an Android machine is returned

Return the code of the IFRAME after append and then let it be re-rendered under

$("#iframe").attr("src",url).ready()
8. Other get IFRAME internal elements
document.getElementById('iframe').onload = function(){let doc = document.getElementById('iframe').contentDocument; }
The middle involves cross-domain requests, but because the background interface is written before, unable to modify the interface, but passed the time Chinese garbled

The interface default resolution is GBK, so you need to set Scriptcharset: ' GBK ',

$.ajax({    type: "GET",    url: url,    dataType: "jsonp",    jsonp: "callback",    jsonpCallback: "data_callback",    contentType: "application/x-javascript,charset-type=gbk",    scriptCharset: 'gbk',    crossDomain: true,    success: function (json) {});});

IFrame-based move-side nesting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.