• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 44
  • Last Modified:

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
0
Rowby Goren
Asked:
Rowby Goren
  • 6
  • 3
1 Solution
 
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy 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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now