Jump to content

JQuery Mobile Full Site


Spunky
 Share

Recommended Posts

Hey everyone, I am fairly new to the JQuery Mobile world, started up when I took a class where I learned about it and have been experimenting through self-teaching since.

 

What I am trying to do is make it so when you go to my site, based on screen size, you get redirected to the mobile site:

<script src="jquery-2.0.1.min.js"></script><script type="text/javascript">function jqUpdateSize(){    // Get the dimensions of the viewport    var width = $(window).width();    var height = $(window).height();	if(width < 699){		location.assign("mobileSite_2/index.html");	}	};$(document).ready(jqUpdateSize);    // When the page first loads$(window).resize(jqUpdateSize);     // When the browser changes size//--></script>

That is what I have in my header. I figure what will happen though if I give the users the ability to return to the full site, that code will only run again, and again redirect them to mobile. My first issue is how to prevent that. Obviously I can't approach the redirecting in the fashion that I am, so I was wondering what the best way is to go about it? I've researched and I know there are ways to detect devices etc. But I recall finding a stuff way back when I first started dabbling in this where mobile versions would automatically load as you make your browser on a desktop smaller and the full site would reappear as the browser window was made bigger. I would like that to occur. But I want the user to have the option to view full site even on a small screen.

 

 

I have additional question that my previous issue led me to. As I was testing the fact that returning to the full site would only detect a small screen where I would then be redirected again to the mobile version, I added this link:

<a href="../index.html">view full site</a>

However, upon "returning" to the full site, although the URL is correct, the page that loads almost within the mobile site code...like, it follows the same JQuery Theme pretty much, which is totally not what I expected. Anyone know the reason for this?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...