Device detection: standard & mobile web applications

Last post 11-11-2008 2:17 AM by sameer_khanjit. 9 replies.

Sort Posts:

  • Device detection: standard & mobile web applications

    12-22-2003, 9:22 AM
    • Member
      15 point Member
    • sion.lewis
    • Member since 10-04-2002, 10:27 AM
    • London
    • Posts 3
    Background:

    I would like to host standard web pages as well as mobile web pages on a single website/virtual directory.


    Questions:

    Is there a simple way of sniffing out the machine type and then presenting either web or mobile application depending on the device?

    Or is there a better solution other than creating separate website?

    Many thanks
    ----

    Mr Siôn Lewis

    sion.lewis@jbcp.co.uk
  • Re: Device detection: standard & mobile web applications

    12-22-2003, 9:28 AM
    • Contributor
      6,278 point Contributor
    • NetProfit
    • Member since 09-23-2002, 11:51 AM
    • Saint John, NB - Canada
    • Posts 1,252
    I don't have a short answer for you, but you could check out the IBuySpy Portal from this website. You can download the source code free. There is plenty of good examples in there, including rendering content for both conventional and mobile web browsers.
    Jamie Kindred, CGA, MCSD
  • Re: Device detection: standard & mobile web applications

    11-03-2008, 5:21 AM
    • Member
      4 point Member
    • graphicguru
    • Member since 11-03-2008, 10:16 AM
    • Posts 2

    Hi this asp code.

    <html><title></title><head> </head><body>

    <% Dim UserAgent, IsPocketPC, IsMME, IsThin UserAgent = Request.ServerVariables("HTTP_USER_AGENT") IsMME = (InStr(UserAgent, "MME") > 0) IsThin = (IsPocketPC Or IsMME) IsPocketPC = (InStr(UserAgent, "Windows CE") > 0) If (IsThin Or IsPocketPC) Then Response.Redirect("http://www.sitename.com/pda")Else Response.Redirect("http://www.sitename.com/index.htm")End If %>

    </body></html>

    save it as Default.asp and works fine im a designer not adeveloper i got it from googling, im looking to work in all mobiles and there browsers when i change to work this script in blackberry i changed "Windows CE" to "BlackBerry" it works fine but not in other do u find any where just post it.

    http://mobiforge.com/developing/story/lightweight-device-detection-asp this link work fine for me. i have changed "Response.Write" to "Response.Redirect"
  • Re: Device detection: standard & mobile web applications

    11-04-2008, 3:50 PM
    • Member
      6 point Member
    • whyknott
    • Member since 11-04-2008, 8:27 PM
    • Posts 3

     Hi There!

     I have found code that truly works in Mobile Redirection but it is in PHP. Can anyone out there help me convert the following Code to function in ASP ??? Thx

     <?php

    if(checkmobile()) header("Location:http://www.jamyershomes.com/mobile/index.html");

    if(checkmobile()){
         //code to execute if a mobile browser is detected
    }

    function checkmobile(){

    if(preg_match("/iphone/i",$_SERVER["HTTP_USER_AGENT"])) return false;

    if(isset($_SERVER["HTTP_X_WAP_PROFILE"])) return true;

    if(preg_match("/wap\.|\.wap/i",$_SERVER["HTTP_ACCEPT"])) return true;

    if(isset($_SERVER["HTTP_USER_AGENT"])){

    $uamatches = array("midp", "j2me", "avantg", "docomo", "novarra", "palmos", "palmsource", "240x320", "opwv", "chtml", "pda", "windows\ ce", "mmp\/", "blackberry", "mib\/", "symbian", "wireless", "nokia", "hand", "mobi", "phone", "cdm", "up\.b", "audio", "SIE\-", "SEC\-", "samsung", "HTC", "mot\-", "mitsu", "sagem", "sony", "alcatel", "lg", "erics", "vx", "NEC", "philips", "mmm", "xx", "panasonic", "sharp", "wap", "sch", "rover", "pocket", "benq", "java", "pt", "pg", "vox", "amoi", "bird", "compal", "kg", "voda", "sany", "kdd", "dbt", "sendo", "sgh", "gradi", "jb", "\d\d\di", "moto");

    foreach($uamatches as $uastring){
    if(preg_match("/".$uastring."/i",$_SERVER["HTTP_USER_AGENT"])) return true;
    }

    }
    return false;
    }

    ?>

  • Re: Device detection: standard & mobile web applications

    11-05-2008, 1:30 AM
    • Participant
      1,837 point Participant
    • SKT_01
    • Member since 04-17-2007, 9:31 AM
    • Germany
    • Posts 413

    Hello,

    you don't have a .NET server?

    I would not recommend those "lightweight solutions" from dotmobi.

  • Re: Device detection: standard & mobile web applications

    11-05-2008, 8:42 AM
    • Member
      6 point Member
    • whyknott
    • Member since 11-04-2008, 8:27 PM
    • Posts 3

     Yes, my host supports ASP. But it doesn't support certain functions in PHP so I want to convert the code in my last post to ASP to avoid complications. I think it may be okay I haven't had much trouble with it so far.

    I have researched and tried implementing that code from mobiforge but I cannot figure out how to get it to work because it is "option explicit". I'm new to programming and I'm not sure how to "comment out the first two lines to avoid compilation errors". as it states on the page you linked to in your reply to my question.

     

    Thanks

  • Re: Device detection: standard & mobile web applications

    11-08-2008, 4:32 AM
    • Contributor
      3,091 point Contributor
    • sameer_khanjit
    • Member since 12-10-2007, 8:06 AM
    • Indore India
    • Posts 638

     

     http://www.codeproject.com/KB/mobile/All-about-a-mobile-websit.aspx

     http://worldofasp.net/tut/XHTM_L-MP/Basics_of_XHTML-MP_178.aspx

    We Are Looking for .NET/PHP Projects

    Contact Details :-

     Email - sameer.khanjit@gmail.com

     Mobile no. : +91-9893795983

     View Blog

    linkedin Asp.net Group

    Don't forget to click “Mark as Answer” on the post that helped you
  • Re: Device detection: standard & mobile web applications

    11-10-2008, 8:51 AM
    • Member
      6 point Member
    • whyknott
    • Member since 11-04-2008, 8:27 PM
    • Posts 3

     Thank You. I will look into converting and be sure to bookmark codeproject.com !!

     

  • Re: Device detection: standard & mobile web applications

    11-10-2008, 9:10 AM
    • Participant
      1,837 point Participant
    • SKT_01
    • Member since 04-17-2007, 9:31 AM
    • Germany
    • Posts 413

    Hello,

    if you use the recommended solution of the Code Project article many mobile devices are not detected as such including one of the most used devices for browsing, i. e. the Apple iPhone.

  • Re: Device detection: standard & mobile web applications

    11-11-2008, 2:17 AM
    • Contributor
      3,091 point Contributor
    • sameer_khanjit
    • Member since 12-10-2007, 8:06 AM
    • Indore India
    • Posts 638

     just go through with me my suggested artical definatly it will work on all mobiles.

    i have worked around  1 yr on the same applications with Mahesh@indianic.com Artical Author

    we have checked around 200 mobile devices and in it's simulators.....

    We Are Looking for .NET/PHP Projects

    Contact Details :-

     Email - sameer.khanjit@gmail.com

     Mobile no. : +91-9893795983

     View Blog

    linkedin Asp.net Group

    Don't forget to click “Mark as Answer” on the post that helped you
Page 1 of 1 (10 items)