I'm basically trying to make one link on my page and when the user clicks the link it will direct to one of these links depending on what device they are coming from.
So the link says "Download Now" and I need it to launch these URL's depending on the user agent device
If Android then android.com
If Windows then windows.microsoft.com
If Apple then apple.com
I am trying to avoid using PHP to accomplish this.
Any suggestions?
You can use the navigator.userAgent and created a method to search for android/iPhone/WindowsPhone etc string within the userAgent string. You'll need to research these online and get a list of all mobile devices and redirect based on that.
You can use the User Agent from JavaScript and intercept clicks on links, redirecting to a page depending on what User Agent is detected. Here's some code to give you an idea: Change link destination based on whether user has mac or PC. Here's a link to various User Agents which may be useful: List of User Agents
Make sure that the link still has a valid href attribute though in case the user disables JavaScript. Another possible approach is modifying all the links: changing the href attribute on page load to fit the User Agent.
Related
i have a dialog in my website's home page that opens if the iphone users are visiting my website for the first time and inside the dialog i'm suggesting users to add my website to their home screen for a quicker access.
i also set a variable to true in cookies that expires within a week for not opening the dialog for the next week if the user visits again.
my problem is that i don't want to show the dialog at all when the user is visiting via the bookmark.
is there a way to do that?
No. I do not think there is a way which can tell you if you were visited by a bookmark or via a browser on the iPhone. You can find out whether the user was an iPhone or Android user, or any OS for that matter.
Once a user clicks a link on their phone, the phone takes them to a browser or opens a "WebView" depending on the link. Even the WebViews might report only the phone type and basic info. when you query for it.
So, basically, No!
you can add one GET when generate url of the marker,
like ?m=1,
to check it from
js with window.location.search
I have a link that on entering it (click/tap), is a confirmation to pay.
The link is sent by sms to the user.
The problem starts when the link is being displayed as a rich preview url, that causes the link to be visited and the user will be considerd to confirm the payment.
Just so you can get a clue as for what is a rich preview (https://richpreview.com/). It happens in messaging services like WhatsApp and iMessage when they display the content of the link before you open it. It complies to the open graph protocol explained here: http://ogp.me/
The question is: how do I disable this rich perview from my end (server side) or how do I detect that this request is for rich preview so that I could ignore the payment confirmation?
One of the suggestions from Google searches was to simply locate the url link in the middle of the text, will it work in all cases?
I had the idea of creating a new page that will redirect (by script) on render to the actual payment confirmation page, is it possible or will the rich preview run this script as well?
Thanks
Removing the http:// or https:// off the front of the link will cause Whatsapp to disable rich link previews.
Unfortunately, using redirects probably won't work. Pretty much, what the rich link does, is it opens its own mini web browser and opens the page for you. If you have redirects the app will just follow these.
Before sending the link, make the server put a dot and a space before the link and a space and a dot after it. See the example:
Sending a the link like this (http://www.bbc.co.uk/news/uk-40909057) will produce a rich link, like this:
However, if you send the same link, just with the dots
(. http://www.bbc.co.uk/news/uk-40909057 .) it does this:
Note: the messaging service removes the dots automatically when it acts upon them, so they don't appear in the message the recipient sees.
I think this should work for you, please get back to me when you have checked it.
The thing that did the trick was based upon the user agent of the request to get the preview.
All the requests for rich preview were from a non-mobile device,
since the platform is solely mobile based, the solution was to detect the user agent and "block" the automatic charge for the user with the non-mobile ua.
instead a button was presented to continue the charge procces for the cases that the device was not recognized as mobile but the proccess now continues with the user intent.
I would like to share an affiliate link that points to an iOS app in Apple's Appstore. Is it possible to mask it or create a sort of proxy to it, in a way that another user can not access it directly while at the same time maintaining its function as an affiliate link?
Its not possible to completely hide it, but it would be possible to hide the url from non-technical users using a few tricks.
You can put an onclick event handler on the link instead of an href attribute so that the user cannot get the URL by right-clicking the link.
Here's a sample code at jsfiddle.
I would like to know on my web page whether the user has loaded the page normally through clicking a link, entering the URL or whatever, or whether the page is from the history and the user came there by pressing the Back button in the browser (or using a hotkey...).
So essentially I'm looking for a method like window.location.canGoForward(). Does something like this exist? If not, what are the workarounds?
I don't care about what happens when the Back/Forward button is pressed, there's plenty of content about that on the web. I just want to query the loaded page about whether it is the latest in the browsing history or not. Wide browser support is appreciated.
You could count the length of the history variable to see if they are new to your site. Here are some helpful links
http://www.w3schools.com/jsref/obj_history.asp
https://developer.mozilla.org/en-US/docs/DOM/Manipulating_the_browser_history
https://github.com/browserstate/History.js/
I've noticed that I've I'm logged in to FB, and someone has posted a link, when I hover over it my status bar (at the bottom...that's status, right?) shows the URL for the story, but if I right click and say "copy link" the link is transformed into one with FB tracking attached. So for instance someone posted a Boston Review story. The screen and the hover text both show that the URL is:
http://www.bostonreview.net/BR37.4/junot_diaz_paula_moya_drown_race.php
But if I actually click the link or right click and say "copy link address" or "copy link location" the URL is transformed to something like this (I swapped in some x's):
http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.bostonreview.net%2FBR37.4%2Fjunot_diaz_paula_moya_drown_race.php&h=wAQG1wXXXXXyoIDSg_ceA9JIXoBRD_o6XXXXXA0Llo4HA
I can use the element inspector to get around it, but I'm curious about whether I can disable that in other ways.
I realize this is only marginally a programming question, since I really just want to tweak my own browser behavior, but I'm not sure where else to ask.
but I'm curious about whether I can disable that in other ways.
You could write your own user JavaScript / browser extension / bookmarklet, that goes through all the links on a page, and if their href has the right format extracts the u parameter and sets it as the new href …
You can't change links on Facebook. All links on Facebook go through their link tracking page. It's probably used by Facebook in a number of ways (user tracking, anti-virus etc). All links in Faceboo, whether through an app or posted by the user manually, will have this long URL passing through l.php.