- This topic is empty.
October 6, 2011 at 12:48 am #88585standuncanMember
So I have a question about this type of script. With using this jQuery method, say you want a “desktop site” type link on your mobile website (like Google has). Well, I have tested on my phone and when I access the “desktop site” link on my mobile site, it correctly redirects me to the desktop site with a href link. However, when testing with a browser on a pc, (minimizing the browser to < 480px) when I access the "desktop site" link, it begins to load the desktop site, but then redirects to the mobile site because of the browser size. Which this is correct in my understanding. But how can I get it to still view the desktop site even if below 480px, (of course only when asked to view the full desktop site)? Seems like it may take some php script dealing with cache or something? Thanks in advance.October 6, 2011 at 10:44 am #88620
Right – when I decrease my IE8 desktop browser to this – if($(window).width() < 480) - then redirects to the mobile page. However, this does not work on my Android smartphone - I still get the desktop version. I haven't made any changes to Dave's code other than entering the proper url. Is this just an Android problem?October 6, 2011 at 10:53 am #88621October 6, 2011 at 10:58 am #88623
Yes. Here is the code – do I have the right syntax?October 6, 2011 at 12:13 pm #88627
After viewing your source I realized that you’re missing this from the top of your document:
Add that at the top of yourand it’ll work. The problem was that without resizing the viewport to the width of the mobile device then the window width isn’t less than 480. Thus the redirect wasn’t triggered.
JohnOctober 6, 2011 at 12:42 pm #88630
Hey Johnnyb. Thanks very much for hanging there with me. After adding the code to the indexTest.htm file it works in my desktop but doesn’t work on my Android. I tried it first at the top of the head area, just before and after the script – same result. I tried rebooting my phone to see if there is a cache problem – nada. The script detects a narrow desktop browser – what could be the problem?October 6, 2011 at 1:54 pm #88632October 6, 2011 at 2:18 pm #88638
I get a text window that says – this should redirect to …. Doesn’t redirect to my mobile site. It does redirect from my desktop IE8. What is so different about Android I wonder? BTW if you want to look at the code in the test page, the file on the site is http://alsautomotiveandtruck.com/ indexTest.htm.October 6, 2011 at 2:29 pm #88641
Just tried it on an Android (Google HTC) and it works in portrait but not landscape, must be the landscape resolution which is throwing it off. I changed the query to 600px and tested on both portrait and landscape and it now works on both: http://johndoesdesign.com/dev/j/redirect/ Test it again on your phone and let me know.
Cheers, JohnOctober 6, 2011 at 3:01 pm #88642
Outstanding! That Worked! Again, thanks for all your effort to help me resolve this.October 6, 2011 at 4:40 pm #88655
Hey no problem, glad we managed to get that resolved!May 16, 2012 at 1:16 am #102881theblizMember
please provide the complete code and make the code redirect just mobile browsers not desktop browsers.May 16, 2012 at 8:15 pm #102934JohnMotylJrParticipantNovember 22, 2012 at 10:39 am #115160dumronMember
Hi, Could anyone help please. I’ve tried your suggestions and cant seem to get a re direct.
This is the source code I’ve tried. any help appreciated.
Untitled DocumentNovember 22, 2012 at 10:49 am #104976Paulie_DMember
That’s not going to work unless you link to jQuery first.
- The forum ‘Back End’ is closed to new topics and replies.