I have a website, with a webpage. I want the webpage to be viewable by mobile devices ONLY.
I know there are ways to redirect a mobile-device-user to the 'mobile' page, but on the mobile page is there a way to redirect a computer user away? (so that it is impossible for a computer to see the mobile page)
You need to identify the user agent then redirect the client to somewhere you want. See if it helps you: http://www.quirksmode.org/js/detect.html
Related
I have 3 steps form, like this:
http://example.com/first-step
http://example.com/second-step
http://example.com/summary-step
I also have profile page:
http://example.com/profile
Requirement is that user cannot get back (using browser's back button) from summary-step to any of previous steps, he/she should be redirected to profile page.
This logic, for some reasons, unfortunely cannot be done on backend side, so only thing remaining is manipulating browser's history. In other words, if user reaches summary-step, previous page in browser history should be replaced from second-step to profile.
Is it doable? Important fact is that this should work not only on desktop, but also most popular mobile devices (iOS >= 7, Android, WP7+). Anchor hacks or adding url's get parameter is also impossible, as long as it hits backend.
This is how you can add your Profile page URL to the history using Javascript!
window.history.pushState('profile', null, '/profifeURL');
My website has a script which redirects users to a landing page with prompts to download our app or return to the desktop site. However, when they hit "Desktop" from their mobile phones, it will loop them back to the landing page. Is there a way to override this once someone has visited the page?
Our website is www.hotshotsnet.com. Thanks!
Well the idea is simple:
You check the cookie "alreadyseen" for 1 in your homepage. If it's not there - redirect to landing page.
once the user hits "desktop" you set the previously mentioned cookie with 1 and get him to your homepage
So now everyone that hasn't clicked "desktop" before will be redirected to landing page. And everyone who did will not have to see it again.
Also don't forget to set expire time and path when setting the cookie.
I would like to redirect any request for my web page to my mobile page (based on the screen size)
We have all layers like Ngnix, SQUID, Spring application.
I'm trying to do it in the web page (the JSP), in the javascript block. But my JSP page where i had my redirect is very huge (I cant fix it now). Its working but, it loads the complete page and then does the redirect, which isnt the optimal thing. Where else can i handle this (Ngnix/SQUID)?
If I'm forced to do it in JS/web page, is there anyway I can do that in without loading the huge page?
Thanks
Mahesh
Check this article out on css-tricks.com by Chris Coyier. In the article he discusses how to mobile redirect visitors based on screen size or targeting specific mobile options.
http://css-tricks.com/snippets/javascript/redirect-mobile-devices/
I have a web App which has links to other web pages. When a user taps one of these links while the app is running from full screen mode the new page opens in full screen as well and so there is no means of navigating back to the web App. Has anyone found a method for escaping full screen mode on the iPad once a web App has been launched from a home screen icon ?
Try redirecting with javascript, like:
document.location='';
We actually consider this a bug, but as always there are those who would see this as a feature :)
If the page your going to is supposed to be in the app, then this solves your problem.
How can I open an external link in Safari not the app's UIWebView?
If the page is any page on the internet, then the answer is pretty much no.
Once you leave the app, there is no way back, except for the user clicking back on your app.
It is not simple to force the ipad to stay in your app. Some suggested methods:
Create your own web view in your app. If your using phone gap, or another framework, you would have to create a plug in to do this. You would then show the loaded pages on that web view, this is similar to how ads are shown & stay in the app.
Parse and replace all the links on the loaded page with custom events, and use a server to return the content, instead of loading it directly via the web.
Both are very complex, and have issues, like you cant have white lists if you let them browse outside specific domains.
My website will revert visitors to a seperate mobile site, this seems fairly simple after reading a few guides online.
However, I would like people to be able to click a link on the mobile site which will then take them to the desktop site.
The problem I see is that if I link back to the desktop site it will just redirect them back if they are on mobile?
How can I get around this?
Really you want to be doing this sort of thing server-side, not client-side. The issue is you're forcing a mobile user (on a potentially bad connection) to download your whole desktop site first (which might be over 1MB), just for the javascript redirect to take effect.
By that point, your mobile visitor may have lost patience and left already.
I blogged about the process here: http://www.9xb.com/blog-2012-08-6-common-pitfalls-when-deploying-a-mobile-site-and-how-they-can-be-avoided/ - if you jump to the bottom of the article, you'll see a flow diagram that maps out the whole process. This particular method uses cookies, but it could be adapted. The beauty of this flow diagram is that it is language independent - you can develop it in any server side programming flavour.
For your convenience, I've included the flow diagram below (although I strongly recommend you give the article a read):
http://www.9xb.com/wordpress/wp-content/uploads/2012/08/mobile-deployment-small.png
The alternative to all of that work, would be to develop a mobile-first responsive site. Not knowing your circumstances, I'll leave it at that - it's not always appropriate in every single scenario.
Make the redirect-to-mobile optional (i.e. a link at the top of the desktop page), or put the mobile redirect only on the initial entry point, i.e. mydomain.com. If they go to mydomain.com/index.html, then don't redirect. That way your 'back to desktop' link can be simply a normal link to index.html, from index_mobile.html or wherever you send them for their mobile experience.
Personally, I would much rather the layout was fluid enough to fit whichever browser anyway, then there is no problem to begin with. Remember, there are now tablets of various sizes to muddy the mobile browsing waters.
Unfortunately you cannot check for the referrer after window.location change. But you can add a hashtag and then check for it.
if(window.location.hash == "#stayHereDude"){
// do nothing, or whatever
} else {
window.location = "mobile/index.html";
}
Then, you'ld make a link to /index.html#stayHereDude on the mobile page.
On your home page that makes the mobile redirect, you'll want to check for something in the href that marks them as having coming from the mobile site. In my case I've used a link to the home page from the mobile site with a ?m=0 at the end of it. For example: http://www.yoursite.com/?m=0
Then you check before the redirect on the home page for that m=0 in the href. if it's there, don't redirect, if it isn't, redirect to mobile.
if (window.location.href.match("m=0")) {
} else {
window.location = "http://www.yoursite.com/mobilesite";
}
This works if you're only redirecting from a single page to your mobile site.
You can use Cookies, Session or Local Storage such that when a user clicks on "go to desktop site", it sets a value.
Let's say you set the name to be "mobileOff" and the value set to "1" or "true" when a user on a mobile phone clicks on "Go to Desktop Site". Then, wherever you're doing your mobile check, add a conditional to check for the mobileOff in the user's cookie/session/localStorage, if it's set to true, bypass the automatic mobile redirect, otherwise, load the main desktop site.
you should combine user agent method to detect device clubbed with query string to this sort of functionality.
so lets assume your link is
site/default.aspx
if some one hits this page check the user agent and give in the response the appropriate site or event better if the device detected if a mobile device simply redirect to m.yourdomain.com/site/default.aspx
but if some one hits the page site/default.aspx?type=desktop then override the behaviour of checking the useragent and render the desktop site.
never ever you should first load the desktop site and then via javascript reditect to a mobile site. do this using user agents server side.
Static
/site/index.html
/site/mobile/index.html
Then you can use a range of things.
Cookies
Session States
User Logged in and Preference Settings (even database saved)
If you're using a static site - becomes more difficult as it gets messy with JavaScript redirects and two many duplicate pages. Post your code and tell us your how you are currently doing your setup and I will update my solution.