Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6063629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:11:21+00:00 2026-05-23T09:11:21+00:00

While I have a successful method of getting users from our mobile site to

  • 0

While I have a successful method of getting users from our mobile site to our full site, I need help getting them from the full site back to the mobile site.

I’m trying to use a combination of CSS and Javscript-written HTML (below) which is using server side detection. Basically the detection determines if the user is on a smart phone and, if so, writes the banner HTML. It should look like this, but unfortunately this isn’t working. PHP isn’t an option.

My question is, how can I get the “View Mobile” banner to appear only on smart phones (i.e. iPhone & Android)?

Here’s my page and code:

<meta name="viewport" content="width=device-width, user-scalable=yes" /> 
<link rel="stylesheet" type="text/css" href="css/mobile.css" media="only screen and (max-width: 640px)" />

…

<body> 
<script type="text/javascript">
<!--
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
device_class = readCookie('COOKIE_DEVICE_CLASS');
if (device_class == 'smart') {
document.write('<div id="view-mobile"><a href="http://m.stanford.edu/">View Stanford Mobile</a></div>');
}
// -->
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:11:22+00:00Added an answer on May 23, 2026 at 9:11 am

    Your cookie is not being set. I visited both stanford.edu and m.stanford.edu, and I do not get a COOKIE_DEVICE_CLASS cookie. If the cookie is created and contains ‘smart’ your code will work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The while loop I have while reading in from a file doesn't break. I'm
I believe that I have successfully impersonated my own user account while running an
Hey dudes.i am having this problem while symlinking. I have successfully deployed a ruby
While I have played with parts of Qt in the past I am thinking
For while I have been trying to set the Page Scaling of Excel page
Its been a while I have ready Mcconnell's Code Complete . Now I read
I'm doing some homework and while I have some experience with SML, Haskell has
If I do an svn update while I have Visual Studio open and a
I've been thinking about this problem for a while and have yet to come
I have an odd problem. I have a unit test that keeps getting stuck

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.