Media query sniffer to redirect mobile visitor to new page

Hello

I need what I think is a media query that will sense when an incoming web visitor is using a cell phone or tablet -- and then will automatically redirect them to another web page in the same domain.

Thanks!
Rowby
LVL 9
Rowby GorenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lenamtlCommented:
Hi,

do you mean 3 levels menu like this ?

Check this snippet:
https://bootsnipp.com/snippets/featured/multi-level-dropdown-menu-bs3
0
Rowby GorenAuthor Commented:
Hi  LVL 27


Actually what is need is this...

A person puts this into their browser.

http://www.banana.com

and because they are using a cell phone they are automatically redirected to

http://www.banana.com/monkey.html

It happens automatically.  The media query (or javascript, or whatever) senses they are on a cell phone and does the redirect automatically.

Rowby
0
lenamtlCommented:
Sorry I have respond the wrong solution to the wrong question....

There are 2 way to do it
one based on device the other based on width, what do you prefer?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Rowby GorenAuthor Commented:
Based on width
0
lenamtlCommented:
You can tried something like this
(more complete version)
<script type="text/javascript">
    $(window).on('load resize',function(){
        if($(window).width() < 950){
            window.location = "https://www.google.com"
        }
    });
</script>

Open in new window

or lite version
<script type="text/javascript">
 
  if (screen.width <= 950) {
    window.location.replace("https://www.google.com/");
  }
  
</script>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rowby GorenAuthor Commented:
Thanks, LVL!   As soon as the redirect page is completed I will try it.  Hopefully later today.

Rowby
0
Rowby GorenAuthor Commented:
Hi LVL

Here's the site.  I put one of the scripts in the head, and it's not working.

The original page is pretty old and poorly writen html. Maybe I need something else in the header.

Link that needs the automatic redirect.
0
Rowby GorenAuthor Commented:
Hi

It's working now.  Stay tuned while I do some more double checking.

Rowby
0
Rowby GorenAuthor Commented:
Thanks.   It worked perfectly   Rowby
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.