iframe iOS fix for V2 code

User avatar
axew3
w3all User
w3all User
Posts: 2691
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

iframe iOS fix for V2 code

Post by axew3 »

Thank to an help by friend with iPAD and iOS devices, i discovered that the fix about correct iframe centered on certain type of phpBB links, in other hand lead to a not correct result on safary and chrome on iOS, that seem for those browsers on iOS the fix isn't required.
To resolve the bug, the iframe code added into overall_footer.html has been easily updated (deeply tested working fine now on any device and OS)

Code: Select all

// fix vertical iframe centered on viewtopic.php, preview or where # anchor etc
$(window).load(function() {
var bd = document.getElementsByTagName("body");
for (var i = 0; i < bd.length; i++) { 
    var bdID = bd[i].getAttribute("id"); 
}
var elt = document.getElementById(bdID);	
elt.setAttribute("style", "position:fixed;top:0%;left:0%;width:100%;margin:0px;");
});
changed into:

Code: Select all

// fix vertical iframe centered on viewtopic.php, preview or where # anchor etc
// skip iOS
var w3iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
if(w3iOS == false){
$(window).load(function() {
var bd = document.getElementsByTagName("body");
for (var i = 0; i < bd.length; i++) { 
    var bdID = bd[i].getAttribute("id"); 
}
var elt = document.getElementById(bdID);	
elt.setAttribute("style", "position:fixed;top:0%;left:0%;width:100%;margin:0px;");
});
}
Related code on procedure hint has been updated about this. To fix just replace the code as above indicated and remember to recompile phpBB template.
wordpress phpBB Iframe procedure V2