Workarounds for iOS that do not support IFRAME

Source: Internet
Author: User

The perfect solution for iOS that does not support IFrame recently made the public page, because the entry is different, you need to extract the public page, and then according to different values, pass to the background of different portals. Initially nested with the IFRAME page (first attempt), but found that the iOS system on the IFRAME nested page height and positioning control is not in place, when the height of the nested sub-page is greater than the height of the parent page, and the child page has a trigger box event, at this time, if the child page height is far greater than the parent page height, will appear in the box can not find the situation, in fact, may be in the viewport below, the location of the box is only relative to the sub-page to locate, and there is no relative to the viewport positioning.

Try a good variety of methods, are not ideal, and the Android system is performing well, then think that the iOS system can directly do page jumps, and Android system is normal use of IFRAME (if the Android system directly to do page jump, there will be problems, so use IFRAME),

Look directly at the code:

<! DOCTYPE html>

<meta charset= "UTF-8" >

<meta name= "viewport" content= "width=device-width,initial-scale=1,user-scalable=0" >

<body>

<script src= "Js/zepto.min.js" ></script>

<script>

$ (function () {

var originid = Sessionstorage.setitem (' originid ', ' 3 '); Originid for background needs to determine which entry is the value

var u = navigator.useragent;

var isandroid = u.indexof (' Android ') >-1 | | U.indexof (' Adr ') >-1; Android Terminal

var Isios =!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/); iOS terminal

if (isandroid) {

Use IFRAME on Android terminal

var Winh = $ (window). Height ();

var iframe = document.createelement (' iframe ');

IFRAME.SRC = "index_common.html";

Iframe.style.width = ' 100% ';

Iframe.style.height = Winh + ' px ';

Iframe.style.border = ' 0 none ';

Iframe.setattribute (' scrolling ', ' auto ');

Document.body.appendChild (IFRAME);

} else if (Isios) {

iOS Terminal direct page jump

Location.href = ' index_common.html ';

} else {

Location.href = ' index_common.html ';

}

})

</script>

</body>

Workarounds for iOS that do not support IFRAME

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.