Need code for mobile browser detection

So I've read there are several different ways to do this using HTML, JS, PHP, Cookies, etc... and found a discussion suggesting to search for "javascript detect mobile browser" which I did, and maybe since the forum is from 2010 the search results are lacking ...here is a link to that forum: http://forums.adobe.com/message/3172216#3172216.
I have code and editing knowlege but not on the developer side of things...I could not write a JS, or PHP if needed...but have created a jQuery mobile site no problem!
Thanks!
~Jenny

You could use either JavaScript or PHP to do this but I prefer PHP, as Nancy said JavaScript can be a bit shakey to say the least across different devices and it may not be enabled.
I have come across a few ways to this but my preferred choice is a project called MobileESP. This project offers a JavaScript or a PHP solution for detecting a massive array of different devices. Because of how complex this project is, I thought I'd explain a very basic way of using the scripts to redirect the client to the appropriate page dependant on what type of device the client is using. PHP is the best solution for this. This script was acquired from there site.
Go to http://blog.mobileesp.com/ and download the PHP version of MobileESP which is a file called mdetect.php.
Put this file in a folder called scripts.
Then for your index.php home page at the site root, add this script below,
<?php
include("/scripts/mdetect.php");
//Instantiate the object to do our testing with.
$uagent_obj = new uagent_info();
//Detect iPhone Tier and iPads...
if (($uagent_obj->DetectTierIphone() == $uagent_obj->true) ||
($uagent_obj->DetectIpad() == $uagent_obj->true))
  { header('Location: http://www.yoursite.com/i/'); } //Edit here
//Detect Rich CSS Tier...
else if ($uagent_obj->DetectTierRichCss() == $uagent_obj->true)
  { header('Location: http://www.yoursite.com/r/'); } //Edit here
//Detect All Other Mobile Devices...
else if ($uagent_obj->DetectTierOtherPhones() == $uagent_obj->true)
  { header('Location: http://www.yoursite.com/m/'); } //Edit here
//Else it's a regular PC browser -- send to regular desktop site
else
  { header('Location: http://www.yoursite.com/d/'); } //Edit here
?>
This script redirects iPhone Tier devices and iPads to www.yoursite.com/i/, Rich CSS devices such as Nokia N95 to www.yoursite.com/r/, Generic mobile devices to www.yoursite.com/m/ and Desktop browsers and all others to www.yoursite.com/d/.
You can also redirect to any file i.e. www.yoursite.com/d/index.html or www.yoursite.com/d/index.js.
Hopefully this should answer your question.

Similar Messages

  • Need code for sales order create report using bapi's

    need code for sales order create report using bapi's

    Hi,
    Go through below link
    http://www.saptechies.com/bapi_salesorder_createfromdat2/
    <b>Reward points if it helps,</b>
    Satish

  • Need code for restarting my system

    hello every body i need code for restarting system
    this code does not work
    try {
    Runtime.getRuntime().exec("shutdown -s -t01") // stop
    }catch(...
    or
    try {
    Runtime.getRuntime().exec("shutdown -r -t01") // reboot
    }catch(...
    or
    try {
    Runtime.getRuntime().exec("shutdown -l -t01") // logout
    }catch(...

    write a jni function that calls this method : ExitWindowsEx()
    check the documentation

  • Need code for Sales order creation in oops using xi as integration server

    Need code for Sales order creation in oops using xi as integration server.

    hi rocky,
              could you pls give a bit explanation on what you are expecting.
    regards,
    Pavan

  • Need code for ITC502

    I need code for gpib to ITC 502.
    Need to set temperature and threshold,
    thankx

    The instruction manual for this instrument is available from Oxford
    Instruments at no charge- they sent me a copy by email as a PDF file. I
    don't have it to hand at the moment so can't dig out the relevant info but
    it would be worth having the full manual, I think. There's a bit more to a
    decent driver than simply setting the temperature, and I'm not sure what you
    mean by "threshold".
    "mdeleon" wrote in message
    news:[email protected]..
    > I need code for gpib to ITC 502.
    > Need to set temperature and threshold,
    > thankx

  • Need code for padding (spacing) 5 navigation links in my #topnavbar internal style

    need code for padding (spacing) 5 navigation links in my #topnavbar internal style

    I'm new at this and the below code is regarding the navigation bar and links
    I started using a template to create the first html page and made copies of it to create the other four.
    All the links work but I wanted to space them apart further.
    They look basically like this horizontally: Home About Us Photo Gallery Services Contact Us
    #topnavbar {
    text-align:center;
    #topnavbar a:link a:visited{
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 100%;
    font-weight: bold;
    color: #039;
    text-decoration: none;
    margin: 0 25px:
    #topnavbar a:hover a:active {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 100%;
    font-weight: bold;
    color: #039;
    text-decoration: none;
          <div id="topnavbar">
          <nav>
          <p><a href="index.html">Home</a>  
             <a href="aboutus.html">About Us</a>  
             <a href="photogallery.html">Photo Gallery</a>
             <a href="services.html">Services</a>
             <a href="contactus.html">Contact Us</a></p>  
          </nav>
           </div>

  • Urgently Need Code for Copy & Paste from Html Table in JSP to Excel file

    I am creating a html table in JSP file .
    I need code for 'Cut,Copy,Paste' functions ie. if someone wants to copy data from my table to excel file or from excel file to html table he shud be able to do that.
    Can someone give me code for 'Cut,Copy and Paste' i.e. some javascript functions which can do cut, copy and paste which i can put in my jsp file
    Thanks
    Message was edited by:
    javatechguru2007

    package com.chinmayananda
    public class Tetris{
    // complete here
    code]
    public abstract class AbstractTetris {
       public abstract void start();
       public abstract void stop();
    }nearly done

  • I want to buy a laptop for my study in college. I need it for web browsing, youtube, words, powerpoint, and light-medium photoshop. Should I buy rMBP 13" or MBA 13" ? Thx

    I want to buy a laptop for my study in college. I need it for web browsing, youtube, words, powerpoint, and light-medium photoshop. Should I buy rMBP 13" or MBA 13" ? Thx

    Either - if you need the 'ultimate' in portability, buy the Air. But whichever you buy, make sure that you max out the RAM and the storage as neither the Air or the Retina MacBook Pro are user upgradeable.
    Clinton

  • I'm new to jsf VWP..i need code for searching

    Hi,
    i need code for search...
    just populate records from database using jsf VWP5.5.1
    how to bind in table.
    we enter name r value in textbox click button related records display to table.how write code in button.
    pls help me....

    Don't crosspost. Please proceed here: http://forum.java.sun.com/thread.jspa?threadID=5211369

  • Mobile Browser Detect

    Hi,
    I've made a new web app using JSP.
    I'm looking for a way to detect if the user is using a mobile browser or not.
    I want to do this in the back-end +(*JSP*)+ rather than the front-end +(*Javascript*)+:
    -> as some mobile devices don't allow Javascript
    -> I don't want to load the "heavy" features +(images, .js files, etc...)+ into a mobile browser
    I would really appreciate any help :)

    I found some info via Google.
    I found a list of "tags" that are present in most mobile browsers, but not PC-based browsers, "User-Agent" header.
    In case anyone else wanted something like this, I figured out a working method of doing this:
    Simply include this file into your application and call it "index.jsp".
    Within the file, change the 1st redirect url from "mobile.jsp" to whatever your mobile page is.
    Also, change the 2nd redirect url from "home.jsp" to whatever your main sites page is.
    The "mobileTags" array holds keywords that are found in most mobile browsers' "User-Agent" header.
    Keep in mind, as new browsers come-out, you will have to update this list....It may make sense to keep a table in your database that holds these tags :)
    <%!
      public String[] mobileTags = { "cellphone",
                                      "iemobile",
                                      "midp",
                                      "mini",
                                      "mmp",
                                      "mobile",
                                      "nokia",
                                      "pda",
                                      "phone",
                                      "pocket",
                                      "ppc",
                                      "psp",
                                      "symbian",
                                      "up.browser",
                                      "up.link",
                                      "wap",
                                      "windows ce" };
      public Boolean isMobile( String browserInfo )
        for ( int n=0; n<mobileTags.length; n++ )
          if ( browserInfo.toLowerCase().contains( mobileTags[n].toLowerCase() ) )
            return true;
        return false;
    %>
    <%
      String bInfo = (String)request.getHeader( "User-Agent" );
      if ( isMobile( bInfo ) )
        response.sendRedirect( "mobile.jsp" );
      else
        response.sendRedirect( "home.jsp" );
    %>
    Afterthought:
    If you want to make your site even more "browser-friendly",
    you could add some Javascript to your "mobile.jsp" page that redirects to your main page "home.jsp"
    Thus, if their browser can handle Javascript, they will be redirected to your Javascript rich page

  • Need code for dialog program

    Hi All,
    My requirement is to create a selection screen with
    1. browse field - selection for the  files to be uploaded
    2. Checkbox - Test run the transaction without parking the entries
    3. Two push button Execute and Cancel
      Execute - to lunch the program
      Cancel - cancel the program and return to menu
    Please provive the code and procedure to create screen. i am new for dialog program.
    Thanks,
    Madhu

    Rather than waiting for someone here to write the code for you, you'd be better off looking at the examples in SAP as already mentioned and reading the SAP help at[http://help.sap.com/saphelp_47x200/helpdata/en/9f/dba66935c111d1829f0000e829fbfe/frameset.htm]

  • Need Code for book publishing in BPC

    Does anyone have any VBA code for generating multiple report tabs?  This would take the place of book publishing since I do not want to create PDFs or HTML reports, but rather spreadsheets.

    I am just noticing this -   did you resolve your issue?   You basically need to write the code.
    Edited by: Deborah Silverman on Mar 16, 2009 7:30 PM

  • Need code for sql update

    HI All,
    i have table with data like this
    select '[email protected]' mgr, null mgr1,null mgr2,null mgr3,'[email protected]:[email protected]:[email protected]'mgrfull from dual;
    1)mgrfull column have with : sepreated email ,here last email split and update to mgr1 column and like this mgr2, mgr3.. Finaly need updated date
    required like this see below
    ----------------------FINAL OUTPUT REQUIRED----------
    select '[email protected]' mgr, '[email protected]' mgr1,'[email protected]' mgr2,'[email protected]' mgr3,'[email protected]:[email protected]:[email protected]' mgrfull from dual;
    Please give me the code for this...

    set linesize 200;
    with tab as
    select '[email protected]' mgr, null mgr1,null mgr2,null mgr3,'[email protected]:[email protected]:[email protected]'mgrfull from dual
    select mgr,
             regexp_substr(mgrfull,'[^:]+', 1, 3) mgr1, 
             regexp_substr(mgrfull,'[^:]+', 1, 2) mgr2, 
             regexp_substr(mgrfull,'[^:]+', 1, 1) mgr3,
             mgrfull
    from tab;
    MGR             MGR1                                          MGR2                                          MGR3                                          MGRFULL                                     
    [email protected] [email protected]                               [email protected]                                [email protected]                                [email protected]:[email protected]:[email protected]
    1 row selected.
    update table_name
    set mgr1 = regexp_substr(mgrfull,'[^:]+', 1, 3), 
         mgr2 = regexp_substr(mgrfull,'[^:]+', 1, 2),
         mgr3 = regexp_substr(mgrfull,'[^:]+', 1, 1);

  • Need code for the problem

    have to create a instance of class if that is the first instance ... successive call to create the instance should return the first instance of the class....i need the code for this pls help me .... even if the code is in C++ its ok

    abhinay.is2006 wrote:
    actually this was the question asked for me in a interview .... i am just a beginner to java and i am not able to get the solution ..My reply actually was a hint: google for "singleton" and you know all.
    kind regards,
    Jos

  • Need code for this program in pl/sql

    Hi,
    was looking for a pl/sql code for the following case
    If there are two employees from the EMP table. i want all the names of the managers common to the two employees....
    to explain in detail : if employee1 and employee2 have the same manager mgr1....mgr1 should be displayed.
    else if employee 1 and employee2 have no immediate manager in common...meaning team leader of employee 1 and employee2 are different but the project managers for both the employee is same..in this case the project manager's name should be displayed......
    else in worst case when there are no managers common between these two employees.........the CEO who is at the highest level is common....then display CEO's name
    it's hierchiacal structure......
    thanks,
    Preethi

    Why PL/SQL? Why not look at if this can be done using SQL firstly? SQL is the preferred language for crunching Oracle data. Not PL/SQL.
    Think data sets.
    One method to do this in SQL would be to build a hierarchical list of managers for each employee. E.g.
    LEVEL MANAGER
    1     Jack
    2     John
    10     Dan the CEOOnce you have such a list for each employee, you can join these two lists on matching names. Then you simply need to find the matching join that has the lowest level.
    I'm sure there are other approaches. But unless you put together some test data, put together some SQLs and play around with this problem, you are not going to learn anything.
    And no, copying and pasting an answer that someone is inevitable to post in response is NOT learning anything new.
    So why not try and solve this problem yourself? Gain some new knowledge. That will only do your career well as your employer is after all expecting you to write the code to solve this problem - and not for members of this forum to supply the code for you.

Maybe you are looking for