JMarqz
July 11, 2016, 11:19pm
1
I’m doing one Ionic App and I’m trying to load some JS/CSS files but only if is iPad. Something like this:
`if ( is_ipad()) :
endif;`
Maybe something like this could be do it in the index.html . The files will be used in all the iPad views but not in the mobile vires.
I know that I can use the Platform Classes but this doesn’t cover my needs. I’m very new in Ionic and I don’t know if this is possible.
Any help is welcome!
Thanks!
Have you tried checking the useragent of the webview?
Extract the useragent using the following:
<script>
alert(navigator.userAgent);
</script>
maxx0r
July 12, 2016, 6:39am
3
I’d add a class to the body for iPads, of wrap the include of ipad.scss in a media query. In the index.html you can load the ipad.js and only init the class when the userAgent contains ipad (or something like that)
JMarqz
July 15, 2016, 9:34pm
4
Thanks to all of you for the answers.
I get help from Stackoverflow too and with this code in the index.html I can load files only for iPad. Can be JS or even link to CSS
if ( ionic.Platform.isIPad() ){
var script = document.createElement("script");
script.src = "PATH_TO_FILE";
document.getElementsByTagName("head")[0].appendChild(script);
}
This is what works for me.
Greetings!