Click here to Skip to main content
15,920,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I was wondering if there was a way to create a simple index.html page and redirect it to a hosted PDF based on mobile and desktop devices? My website is not up yet but i want people to at lease see the menu.

So example now i have the site mysite.com and the PDF is hosted at mysite.com/menu/. If someone is visiting mysite.com from a mobile device (tablets not included) they should be redirected instantly to mysite.com/menu/mobile.pdf. But if they are visiting mysite.com from a desktop and tablet devices then they should be redirected to mysite.com/menu/desktop.pdf

What I have tried:

Is this possible? Any help would be appreciated. I figured how to add a link that redirects to desktop and mobile PDFs based on devices but its not user friendly to have to click and go to the PDF. An auto redirect seems logical. Thanks in advance everyone.
Posted
Updated 30-Jun-22 4:34am

1 solution

In a word, "don't". Do not redirect to a PDF.

That doesn't show a page but triggers a download by the browser. Users will look at that and think you just redirected them to malware.

You ALWAYS make sure the user knows what is coming with the next click. If you want them to get a PDF, you MUST tell them ahead of time so they don't freak out when you throw a file download at them.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900