开发者

Simplest way to redirect a mobile phone away from a website with Flash [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 2 years ago.

Improve this question

Very simply put, I have a Flash heavy website. I also have a PDF version of the information on the website. I want to add determine the browser (or platform) requesting the site and if it is a mobile device (or Flash unsupported device, i.e. iPhone or iPad) redirect the user to the PDF.

I think it should开发者_StackOverflow be some simple Javascript, I just have never dealt with needing this behavior from a site before.


I'd advise you to use a server side check like PHP, because most mobile browsers do not support javascript. Check if the user agent is mobile then redirect.


I have not used either of these methods myself, but here are two examples I found after a quick search:

http://www.hackingethics.com/blog/2011/02/06/how-to-redirect-your-website-to-mobile-website-on-mobile-devices-by-javascript/ This one tests whether the navigator is one of several mobile types, and then redirects.

http://css-tricks.com/snippets/javascript/redirect-mobile-devices/ This one has a method of testing the screen size. If the screen is small enough to be mobile, it redirects the browser to the mobile version.


Since mobile devices (or at least tablets) are starting to support Flash, I wouldn't blanket reject anything with a "Mobile" in the query string. Instead, I would recommend feature checking. Since mobile browsers have limited bandwidth, charge for data transferred, and may not support PDF's, I would also recommend making the navigation to the PDF optional.

<script type="text/javascript">
    if(!navigator.mimeTypes["application/x-shockwave-flash"]) {
        if(confirm('Your browser does not support flash?  Would you like ' +
                   'view the PDF version? (25kB)')) {
            location.replace('static_file.pdf');
        } else {
            // Show some "We're sorry" content.
        }
    }
</script>
<noscript>
    <p>This requires Flash.  <a href="static_file.pdf">Click here to 
    view the PDF version. (25kB)</a></p>
</noscript>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜