Redirect mobile users loop - javascript

I have a site that will redirect users to a mobile version of the site if they're browsing on a mobile device. The redirect works fine, but the problem comes when getting them to switch to the desktop version of the site.
If you visit site.com on your mobile, you'll be redirected to m.site2.com (as the mobile version is hosted on a seperate website - confusing I know but it's had to be done this way). Then if the user clicks 'View full site' on m.site2.com, they'll be sent to site.com, but then immediately sent back to m.site2.com.
Is there some code I can put somewhere that specifies if the visitor has come from m.site2.com then it will override the redirect?
This loop is driving me crazy. Also, it has to be in Javascript. If anybody could provide a full script for this I'd really appreciate it!
Thanks

Perhaps setting a query var, or header data can solve Your problem. Checking the referrer can also help.

It's always better to redirect to mobile from the server itself. In your case, you are redirecting from the client side, using JavaScript, right?
I have two solutions.
ONE: disable automatic redirecting. You can provide a "Desktop Site" link on your mobile version and "Mobile Site" link on your desktop version. If users like, then they can choose mobile or desktop.
TWO: create two identical HTML files in your Desktop Site server. Say index.html and index2.html. The difference is, index2.html doesn't have the redirecting Javascript code.
Now redirect the people from the Mobile Version to index2.html at your Desktop Site.
That is, in solution TWO, the flow can be like this:
User → Desktop Site (index.html) → Mobile Site → Desktop Site (index2.hml)
Here you can see, the user first comes to the Desktop Site, in index.html and automatically redirected to the Mobile Site. But the user then clicks to see the Desktop Version. There you should provide the link to index2.html, and then the user is not redirected automatically as the script is missing in index2.html

Related

How can I open a mobile app (eg Facebook) via a browser redirect?

I've been searching for the past few hours for this and decided I'd just try asking.
I have a URL that people will visit, it loads a PHP page which checks a database for a specific Facebook link, and then instantly redirects them. I want it to open the app if they have it, otherwise it will go to the browser version.
The issue I'm facing is that I can't get the Facebook app to open when it's a redirect. If I instead create a button or a link and I tap on it, it will launch the app correctly, but navigating to that same link without the user interaction will not work.
I know it's possible because I've seen it done elsewhere, but I guess there is something I'm missing.
I've tried using headers("Location: fb://profile/username") and have also tried other Javascript options such as window.open, window.location, window.location.href and window.location.replace
So far I've only tested this an on android phone. The link initially launches in the chrome app.
If you have a look at this Youtube video, you'll see it's doing what I want to do. It goes to a website and then straight away launches the app.
https://youtu.be/Acl7JnRFxzI?t=17
Thanks!
I think you talked about Deep linking.
Deep linking is not supported on Web so there aren’t the same functionalities as on Android and iOS. You still need to guide your users in the right direction, so we recommend adding a link to your login page.

Custom URL without "cannot open" error

I've implemented custom URLs in my app, and they work fine. I've also implemented custom landing pages that show different videos based on a query parameter.
1) I would like to generate links for Twitter, email, etc. that launch my app if the user clicks on a link on a mobile phone. If the user does not have the app installed, it should go to the landing page in the mobile browser. The link should go to the landing page if clicked on major desktop browsers.
2) On the landing page, I would like to have a link to open up the app. If the app isn't installed, the link should open the app store listing.
On StackExchange and Google, I've found these proposed solutions:
A) http://mobify.me/static/tests/test-app-link.html
B) http://aawaara.com/post/74543339755/smallest-piece-of-code-thats-going-to-change-the
These solutions are for part 2) above. However, even the canonical version like A) still generates a "cannot open" error in Mobile Safari before redirecting.
Can anyone tell how to write a redirect service for 1) above?
I'd also love a pointer to a good example of how to handle 2) without a error alert box.
You question is fairly long but I am pretty sure this link is what you are looking for: http://support.mobileapptracking.com/entries/25539969-How-to-Deeplink-to-Your-Mobile-App-from-Your-Website
We used the concepts to create something similar to what you are looking to do.
OK, my friend and former CTO gave me an awesome pointer. You can use a iframe to check, which is a solid technique. He has an example, which I can confirm works well on mobile safari.
Here is the code and example on github:
https://github.com/hampusohlsson/browser-deeplink
Hope that helps!

Internet app calls intranet page

This is not so much of a specific question, but more a general one. I'm redoing one of my old projects and to make it more user friendly I want the following:
The project will be running on my home server, with a flask/python backend. User using my website will be coming from my companies intranet. Would it be possible to load an intranet page in a iframe on my website.
So in short, is it possible to load an intranet page from an internet-page that has no access to said intranet.
Of course you can load it in an iframe, you don't need access to the page from the internet for that - the client needs it. Yet, the intranet application might request not to be viewed in a frame.
Yes. Any page that the user can browse to normally can be loaded in an iframe.

Two browsers on different machines view the same page

I am thinking of a remote help application where a user needs help navigating a web site.
How can a second user see what the first user is seeing so they can help them over the phone.
Could both users interact with the website?
Is there a solution that will work in any browser that requires no special downloads. I can imagine a simple system where the user browser updates the server with the current location URL but how to see the mouse clicks and dynamic Javascript changes etc.
Edit: This is called "cobrowsing" see wikipedia for a list of solutions
Why not use an existing screen-sharing solution, like http://join.me ?
unblu allows two users to interact with the same website
requires no download
works with Javascript/AJAX etc
works of SSL
can be either cloud or privately hosted
There are others that I have not investigated - you can see a list in the cobrowsing wikipedia page.

.htaccess or JavaScript Redirecting

I have a mobile site at m.site.org and the main site at site.org I am using htaccess to redirect other pages but not sure if it's useful in this case.
If people are on a mobile phone and they go to the main site I want them to be redirected to the mobile version. Once on the mobile version we have an option to go back to the full site so I don't want them stuck in a redirect loop and can't go to the main desktop version.
I can not use server-side code and would like to know if there were an option without JavaScript (doubtful).
EDIT:
The link site.org I would like redirected but NOT site.org/index.html through htaccess. Possible? Does this help?
You should check this out. It provides regular expressions you use against the user-agent that can be done client side, and it is open source.
You can download an htaccess or get JS from it. Then edit at will. The htaccess gives you a rewrite cond. JS will give you a function.
Now this won't scale if a new phone comes to the market, but it's pretty decent and you can change it as new things come. Or you can run a process that fetches and deploys the new regular expressions periodically
Without touching the server, or adding JS, it's going to be difficult.
If you can check for the HTTP_USER_AGENT header on your server, you could display a HTML redirect:
<meta http-equiv="Refresh" content="0;URL=http://m.site.org" />

Categories