简体   繁体   中英

How do I adapt a specific web page to iPad users

I have created a special folder within my website directory for iPhone (NOT iPad) users. On my index's heading I have the following code: <script type="text/javascript"> if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)) { document.location = "mobile/";}</script>

I want the website to be regular for iPad users, except for a specific page. I want this particular page within the website to be different for iPad (NOT iPhone) users. How do I do that?...

If you do not wish to include a specific JavaScript file, check the window.location.pathname inside an IIFE.

<script type="text/javascript">
    (function(){
        if(window.location.pathname === 'specific-page') {
           // insert CSS or change stuff
           return false;
        }
    })();
</script>

But seriously, just add a custom JS file inside the HTML for this page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM