Determine which browser is being used to visit my site - javascript

Can someone tell me how I can determine (using JavaScript etc.) what browser is being used to visit my site?
I want to redirect to a different page based on these scenarios:
Wheater the user is browsing using Safari on the iPhone.
Using IE on a desktop
Using IE on a WP7 mobile device.
Thanks.

Check out the Javascript Navigator object:
http://www.w3schools.com/js/js_browser.asp
alert(navigator.userAgent);
This script may help you for more complicated detection:
http://www.quirksmode.org/js/detect.html
You should be handling these redirections server-side though. This is particularly true if you have a mobile version of your site. Most mobile browsers do support Javascript just fine, but there are quirks.
Server-side, you can send a redirect by sending the 302 status code, and the location: header. See http://en.wikipedia.org/wiki/HTTP_location
Edit: Since you say that you need to detect mobile browsers now in your comments, just use this script: http://detectmobilebrowsers.mobi/

Related

iOS Browsers except Safari Keeps asking camera permission every time I load the page

We are currently developing a qr code scanning system using laravel but when I test it on Chrome or other browser except Safari, it always ask camera permission.
I have already allow camera permission on browser setting on my iPad. Is there other way to permanently allow it or only ask once on Chrome browser like on android that remembers my choice? Or is it possible to do it programmatically like using Javascript?
thank you so much! I really need everyone's help, I couldn't find any related topics on the internet about this 😄
There is no API for the PWA's to change it from "Ask" to "Allow". There is an issue on WebKit around this: https://bugs.webkit.org/show_bug.cgi?id=215884, but what can you do is to change it manually in browser settings, as it was mentioned: https://stackoverflow.com/a/57368061/615393.

How to open Safari browser from any other browser in javascript?

I'm working on the core Php(PHP + bootstrap + jquery) website and I want to open the safari browser from any browser with a special URL.
IOS users are using many kinds of web browsers but my site is working on the only safari with ios users.
So when IOS users call a special URL, the safari browser should open with this URL.
I think I may use javascript functions.
Please let me know if you have any good solutions.
Best Regards.
You can't.
JavaScript does not have that kind of access to your system.

Facebook login (from Like button) stuck after entering credentials

I have embedded the Facebook Javascript SDK in my website as well as a like button for a specific facebook page.
When a user clicks the like button and wasn't logged into Facebook, their login process triggers. This works fine in desktop browsers and recent Chrome/Safari versions for mobile devices.
I do, however, need to use QR codes to get people to my site. Some QR code reader apps open URLs in their own crippled browsers (e.g. "QR Code Reader" for Android).
These browsers get stuck after someone enters the credentials and clicks "Login" (the URL at this point is extremly long, starting with "https://www.facebook.com/plugins/close_popup.php?reload=https..."). Could this be due to their lack of tabs?
Is there any way to fix this or can I at least check the user's browser (in Javascript) and show them a message, that they should open this page in a current version of e.g. Chrome/Safari?
edit:
Okay, I somewhat got it to work by using this solution and only allowing certain detected browser versions (Safari & Chrome 4+, Opera, IE 10+). It's not ideal and seems fragile, but it works for now. I'd still prefer the login working on those browsers, though. :/

Google+ JavaScript API Login Popup not returning Chrome on iOS

I am using the Google+ Javascript API log in button and it works perfectly fine in Chrome on Windows and Android. It also works perfectly fine in Safari on an iPad and iPhone. However, when using Chrome on the iPad or iPhone, the pop-up tab for the Google log in never returns after clicking to allow access. It seems to be submitting the form to the pop-up tab and never directing back to the original tab. Any ideas?
Google knows about this issue, but currently cannot do anything about it. It comes down to window.open not working in UIWebview.
Safari is not limited by App Store rules the way all third-party apps
are. Apple can use any WebKit APIs they want to, whereas we are
constrained to what is possible using UIWebView.
They encourage anyone facing this issue to open a bug with Apple.
You can't make Apple do anything, but anyone affected by this can
file a bug against Apple about the fact that UIWebView doesn't support
window.open and subsequent cross-site scripting, to clearly
communicate demand for that support.
There's no way for people to add votes or comments to existing Apple
bug reports, so the usual advice is for everyone to file their own.
Here's the URL for bug reporting in Apple: https://bugreport.apple.com
Here is a sample bug posting to Apple provided by one of the users:
Summary: Please add support for window.open and subsequent cross-site
scripting to UIWebView. This is blocking Facebook/Twitter/etc login
workflows in Chrome for iOS for example
Steps to Reproduce:
1. In a tab, open a page that runs the code var w = window.open(yourURL, null, null);
2. The page at yourURL should try to accesswindow.opener`, such as to postMessage back to the original page
3. Don't profit.
Expected Results: New window can access window.opener.
Actual Results: window.opener is undefined.
Version:
7.0.4
Notes:
Configuration: Chrome Version (from "Settings > About Google Chrome"):
19.0.1084.60 Device Type: iPad 3
You can follow the issue thread for updates.

Enable and Popup blocker in IE

I wrote a scripting logic in using ActiveX. When the application runs it is blocked by popup blocker. When I enabled it works fine, but I want to enable the popupblocker using JavaScript (especially in IE).
Obviously a website cannot modify the popup blocker settings. And that's a good thing.
You should avoid using ActiveX Controls because it is only supported by IE. Trying running your page on Firefox and it won't work.
Now the actual problem -
Firstly you need to understand what ActiveX Objects are used for? They basically allow a web application to interact with the client machine. For example it can use resources on my local hard drive. This is a security risk. So IE gives a warning for the same. You may disable it in your browser by going to Tools-> Internet Options -> Security Tab. Click "Custom Level" and change all the boxes with ActiveX text in it to "Enable".
But it will still show up in your client browsers.
So the point is try finding an alternative for it.
Hope this helps!
You cant. What you could do is have a message on screen which requests the user to turn off the popup blocker .

Categories