I have a website, https://coolkids.gq. I’ve asked a lot of questions on this site because I’ve been through many different methods to attempt to create the perfect non-proxy website cloning script.
This (hopefully!) will be the final question on the matter. The final issue is with iOS. There is this weird scrolling effect where you can continue overscrolling/rubber banding past the main area of the page you can normally see. This means you can see stuff that’s normally hidden behind the edges of the <body>
. In my case, if you use iOS, especially safari, you can scroll up on the iframe and see an advert banner from the ‘CMS’ I’m using for the homepage that I hid by setting 50 pixels of the iframe to be hidden above the top of the page.
I need to load a seperate stylesheet for iOS to solve this that makes the page and iframe really long and then stops people from scrolling inside the iframe, but allows them to scroll the body, allowing them to see the rest of the iframe because it’s in a fixed position along the very long page.
First of all, how do I make it so a user can’t scroll in an iframe (it’s cross domain and I don’t have much control over it) but can still touch buttons in it?
Second, how can I use JavaScript to change the CSS? Here’s the code I’ve tried so far:
var _iOSDevice = !!navigator.platform.match(/iPhone|iPod|iPad/);
if (_iOSDevice == ‘true’) {
document.html.style.height = “400 % ”;
document.html.style.overflow = “hidden”;
document.maincode.style.min - height = “calc(1000 % +50 px)”;
alert(“iOS is being used”);
} else if (_iOSDevice == ‘false’) {
alert(“iOS is not being used”);
}
The alerts are just there for testing purposes.
The bit that detects whether iOS is used or not works fine - I tested it by putting alert(_iOSDevice)
and it always alerted true on iOS but false anywhere else.
However, my if () {}
code doesn’t seem to function, as the CSS doesn’t change on iOS and neither of the two test alert()
systems function.
So how do I:
- Stop users from scrolling in my iframe but allow them to touch buttons
- Fix my JavaScript to change the CSS for iOS users so that they can’t scroll in the cross domain iframe but can press buttons in it?
For number 2 I think I’m going to make a really long page and then stretch the iframe to fit that so it doesn’t need to scroll because the page always fits inside of it, then disable scrolling in the iframe, but I’m not sure how to do this.