I need an html code..

I need an html code the redirects anyone not on a mobile device, or a tablet .. something like if resolution is greater than *  redirect to * .. is what i was thinking..  anyone know what im talking about?

MY SITES http://viptopia.net general social networking | http://www.rangerschat.com/ niche site
Quote · 10 Apr 2013

something like this should work

define('DA_URI', 'http://detect.deviceatlas.com/query');
$da_json = @file_get_contents(DA_URI . "?User-Agent=" . urlencode($_SERVER["HTTP_USER_AGENT"]));
$da_results = (array)json_decode($da_json, true);
if ($da_results['mobileDevice']) {
    header('Location: http://mobile.mobi/');
}

caredesign.net
Quote · 10 Apr 2013

Just an FYI - please keep in mind that some mobile devices have an option to switch from native mobile to desktop viewing of a site. Do not know if these instances will still be redirected properly.

caredesign.net
Quote · 10 Apr 2013

well yes and no,, i need html it is for an html page not php it is not for the dolphin site itself

MY SITES http://viptopia.net general social networking | http://www.rangerschat.com/ niche site
Quote · 10 Apr 2013

 

Just an FYI - please keep in mind that some mobile devices have an option to switch from native mobile to desktop viewing of a site. Do not know if these instances will still be redirected properly.

 yes that is why i was thinking of it would be best to determine resolution

MY SITES http://viptopia.net general social networking | http://www.rangerschat.com/ niche site
Quote · 10 Apr 2013

i dont know if there is a purely html waqy to do it without using either php or javascript, but I still have a lot to learn. Hopefully someone else can jump in and help. or you can just change the page from whatever.html to whatever.php and you wont lose any existing functionality

caredesign.net
Quote · 10 Apr 2013

it is to keep people from using my mobile chat with desktops.. i want people on computers to use the regular flashchat on my site not the mobilechat

MY SITES http://viptopia.net general social networking | http://www.rangerschat.com/ niche site
Quote · 10 Apr 2013

 in my previously mentioned code, the response from the server would be

{"displayWidth": 240, "mobileDevice": true, "displayHeight": 320}

so you would have to do some changes if you want to use the screen resolution as your identifier.


Also - after further thinking about it, you would have to use either php or javascript to do your redirect anyways - reason I am thi8nking:

You are saying if something exists then redirect - which from my understanding you wont be able to do with just html

a simple php version would be

if (displayWidth >=480) {
header('Location: http://desktop_site.html/');

}

caredesign.net
Quote · 10 Apr 2013

what about this:

<script type="text/javascript">
if (screen.width<800)
{
window.location="http://yourdomain.com/mobile/"
}
else
{
window.location="http://yourdomain.com/"
}
</script>

Sorry - I was having a  brain lapse for a minute - i used this on a site about 4 years ago and forgot all about it till just now.

caredesign.net
Quote · 10 Apr 2013

trying this now

MY SITES http://viptopia.net general social networking | http://www.rangerschat.com/ niche site
Quote · 10 Apr 2013

<script type="text/javascript">
if (screen.width>800)
{
window.location="http://yourdomain.com/mobile/"
}
</script>

WORKED!!.. ty

MY SITES http://viptopia.net general social networking | http://www.rangerschat.com/ niche site
Quote · 10 Apr 2013

sorry i took you the scenic route - must mean it is time for me to go to bed

caredesign.net
Quote · 10 Apr 2013

oh - just another fyi - your example above of >800 is going to mobile site and not the desktop - it would be <800 goes to mobile

caredesign.net
Quote · 10 Apr 2013

it wasnt for my mobile SITE ,, it was for my mobile CHAT,, so i put it in the html for the mobile chat itself

MY SITES http://viptopia.net general social networking | http://www.rangerschat.com/ niche site
Quote · 10 Apr 2013

one last thing - i believe that an ipad will still redirect to your desktop chat cause the screen resolution is higher than 800, so if you dont want ipads to use the desktop chat then reduce the resolution.

caredesign.net
Quote · 10 Apr 2013

It's not a good idea to try and detect mobile browsers using javascript, or to use screen resolutions.  You should do this server side using php to detect user agent strings. Here's something I found:

<?php
$useragent=$_SERVER['HTTP_USER_AGENT'];
if(preg_match('/(android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i',substr($useragent,0,4)))
header('Location: http://yoursite.com/mobilechat');
?>

 

That will send mobile browsers to yoursite.com/mobilechat.  To also detect non mobile browsers, use the exact same code, only put a ! before if(preg_match, like this if(!preg_match.... the you can send non mobile browsers somewhere else like this:

 

<?php
$useragent=$_SERVER['HTTP_USER_AGENT'];
if(!preg_match('/(android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i',substr($useragent,0,4)))
header('Location: http://yoursite.com/notsomobilechat');
?>

 

You can put the code in both places so all browsers end up in the right place.

My opinions expressed on this site, in no way represent those of Boonex or Boonex employees.
Quote · 10 Apr 2013

@hl, its good to know that it isnt a good idea to use javascript to redirect based on resolution, havent done it that way in years, and that was because i was Iframing a gaame and it mattered what resolution you had. I just use this like I posted before and it works for me:

define('DA_URI', 'http://detect.deviceatlas.com/query');
$da_json = @file_get_contents(DA_URI . "?User-Agent=" . urlencode($_SERVER["HTTP_USER_AGENT"]));
$da_results = (array)json_decode($da_json, true);
if ($da_results['mobileDevice']) {
    header('Location: http://mobile.mobi/');
}

caredesign.net
Quote · 10 Apr 2013
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.