JavaScript/Webcal - Protocol detection? - javascript

I'm getting ready to release an iCal subscription feature, and I'd like to set the protocol to https:// or webcal://, depending on browser support. I'm aware that webcal is an unofficial protocol, but is there a way I can check if the browser supports it? So far nothing seems to make it work in IE8, and I'm about to test IE9+, but I'd prefer to offer graceful degradation for all browsers that don't understand webcal:// (as I understand it, the Android browser also appears to have issues with it).

Related

How to detect client's web browser is Vivaldi?

I've tried on getting browser info from javascript - navigator.userAgent, but cannot find any related string with "Vivaldi".
Please help to suggest if there are any other programming method or javascript can be used to detect Vivaldi browser?
The correct syntax in JavaScript is navigator.userAgent.
You can check window size, but it may be incorrect.
Vivaldi has its own sidebar and bottom bar that the others not.
But remember, user can change the window size to prevent detection.
According to Vivaldi, the userAgent will not have Vivaldi in it for a better user experience and mimic Chrome in all sites except a few known ones.
For the next release of Vivaldi, we have decided to try something different. The problem with our current approach is that with the web being almost infinite, we can’t possibly discover all the websites who have blocks set against us. Thus maintaining a list of sites where we present a non-Vivaldi User Agent is difficult. Instead, we will try doing the reverse. For a handful of sites where we know the label Vivaldi (and our version number) is responsibly used, we will present our full User Agent. Those sites being our own and a handful of interesting alternative search engines: duckduckgo.com, ecosia.org, qwant.com, and startpage.com. Every other site will get a User Agent that appears to be identical to Chrome.
src: https://vivaldi.com/blog/user-agent-changes/
Since you haven't mentioned your use case, assuming you are building sites, the best solution would be to do what everyone does. I recommend building websites agnostic to browsers and devices, but responsive to resolutions and feature support. Almost all of the browsers are running on Chromium these days, except Safari and Firefox (to my knowledge). So they are all going to work consistently across the board. For any given feature, one could always refer to w3c or mdn docs for compatibility and build around that.
Browser detection is also not quite reliable, as there are extensions to spoof the information. Like this extension that mimics a TV agent so one can run youtube console version on it.
On the other hand, once again I don't know your use case, one might benefit from platform detection over browser detection, like catering to mobile and TV users. Even then, if you have a site responsive enough the platform becomes non-essential information.

How to check the last available version of Chrome and Firefox using C# or JavaScript?

One of the requirements of one of my clients is to show a message to a user that's using an older version of Firefox, Chrome, IE or Safari. For the last two it's easy (IE 9+ and Safari 5+). But for Firefox and Chrome, the requirement is that the site supports the current and the previous version of each browser.
To get the clients browser and version is quite simple, but I need to know what is the last version of each browser. Is there any way of doing that?
Well, technically, all you need is a place that keeps track of what the latest version of each browser (Ideally with a web service).
A quick Googling I was able to find: http://www.webdevelopersnotes.com/articles/latest-browser-versions.php
It's not a web service, but you could simply parse that HTML and get the latest version of each browser. Alternatively, you could keep track yourself and manually update this information in your database.
You should only ever have to worry about IE when it comes to version enforcement. Exception being, of course, if you need a specific API that's just not available in previous versions of Chrome/Firefox, but in that case you'd look and enforce the API, not the browser version. Adding to that, if Chrome/Firefox don't have an API, chances are even the most bleeding edge version of IE won't either, so the point is moot. The fact is Firefox and Chrome, and in part Safari, are far ahead of IE when it comes to browser hosted capabilities that trying to enforce specific versions of the former would likely be a lot of wasted time and effort to yield nothing substantial.
The best I could find was this. It has an export option that allows to export in JSON, XML...
I would strongly suggest that you don't check the browser version, instead try doing feature detection using, say, Modernizr.
What features of your client's site depends on specific versions of each browser? If you use Modernizr you could perform a check on a feature, say some video stuff, and if the current browser does not support that feature, then display a message to the user suggesting they upgrade their browser.
Detecting browser versions via Javascript is very flakey at best.
The only reason I'd say you need this kind of verification is because your webpage has features only available to latest browsers. Instead of relying on version numbers, I suggest learning Modernizr.js for your website.
http://modernizr.com/
It can detect particular html5/css3 features individually.

Do I still need to test rendering in both Chrome and Safari if they both use Webkit?

Is it necessary to test the rendering of my website in both Chrome and Safari despite the fact that both browsers implement the Webkit rendering engine underneath?
Is this a cop out by developers or a valid assumption to make?
I am specifically asking about whether the pages of my website will render the same in both browsers and whether my Javascript will work in both browsers.
There are some slight differences, so I would test in both. Some examples:
By default Safari has 3rd-party cookies disabled, but Chrome has them enabled by default.
Safari does not store <noscript> content in the DOM, Chrome does
Chrome keeps each browser window sandboxed in its own operating system process (multi-process model). Safari keeps all windows in one process. [Note though: The upcoming WebKit2 will have support for the multi-process model built in].
Chrome uses the V8 javascript engine, Safari uses Nitro.
I know there a few other differences I have encountered, but I can't remember them off the top of my head. I'll update this post if any occur to me.
They use different JavaScript engine, Chrome:V8, Safari:Nitro
Each browser may choose to include different features of webkit in their final versions, so they are not always the same.
Even different versions of Chrome will behave differently, same for different versions of Safari. So I wouldn't use this assumption, and would test in both browsers.
Interesting question, I was thinking about this earlier. I would say yes, just because the rendering engine is only one part of the browser. You also have to take into account that there are many versions of each browser still in use.
It doesn't take too long to test the page in ether, better safe then sorry.

Is there a way to port a chrome extension to other browsers?

Is there a way to port a chrome extension to other browsers, without having to entirely re-write the code? My chrome extension uses the browser_action command to open "popup.html" in the extension window...
Update: I found adblockforchrome port.js and found it only somewhat helpful for porting to Safari...
Apple provides some guidance on how to port convert a Chrome extension to Safari, but the problem you're going to run into is that each browser has a different set of allowed functionality for extensions. Even with Chrome to Safari, there are things you could do in Chrome you can't do in Safari, and visa versa.
It depends on the type of the extension, but not really. To answer your question more clearly, you need to specify what your extension is about: modify some pages (like userscripts/userstyles), extend browsers' features, or something else.
There are a few portability notes, however, that could help you to simplify this process:
Don't write browser specific code. In some modern browsers you're able to use HTML5 features, like Web SQL Database API. It is difficult to emulate such behaviour on IE, for instance.
Keep your JavaScript modular; don't use vendor specific JavaScript methods, and your code will be portable and will not rely on TraceMonkey or V8;
Separate HTML from CSS and Javascript, don't make your code dirty and complicated.
Jumping in a bit late.
Our company - Slice Factory (full disclosure here!) does provide a browser extension conversion service: http://gallery.extensionfactory.com/labs/conversion/
In most cases your chrome extension will work seamlessly in FF and Safari.
The service is still in beta trial, and Firefox conversion is working better than Safari one.
I can't fully disclose what's our technical solution, but this being an SO answer, I can add a few details: we have re-developed a full javascript api stack that mimics most of chrome extension APIs for Safari and Firefox; in Firefox we base our work on JetChrome. Plus we have wrappers that re-package the chrome extension adding our library and rewriting manifests and so on.
Beyond that, it's mostly a few good ideas, trial and error, and a LOT of development time.
As an example:
Safari 5.1 just introduced a popup corresponding to Chrome's browser_action, but we have already an alternative solution that works for previous versions. Firefox does not support HTML5 WebSQL, but we have an API for it. We also provide a way to bring webapps to FF, and soon to Safari.
The objective is to have Chrome API as a reference, and mimic it on all the other browsers.
Without pushing you towards our solution, I might add that the time to fully cover the Chrome API on both Safari and Firefox is probably not worth it - unless you plan to convert several extensions. So for just one or two extensions I would advise making your code as modular as possible, and just creating three extensions - or trying our service!
Yes, it's possible with Webextension API using webextension-polyfill.
I made use of it to build this where I only had to change the callback methods to Promises and using browser.something instead of chrome.something to call the browser APIs.

Prompt user to "Open firefox" if the website is opened in "IE"

I have a website,which is "currently" designed & tested to work only on firefox.If user tries to open it in other browser then I want to show a popup saying "This site works best with Mozilla Firefox. We're working hard to add support for your favorite browser. Meanwhile, do try it with Firefox."
Can we provide a buttion on clicking of which, one new window will be opened in firefox preloaded with some URL ? and also tells us in case firefox is not available at its default location ?
Thanks,
Sourabh
If you make your website standard-conformant, chances are pretty high it will work in Firefox, Opera and WebKit-based browsers (Safari, Chrome), without having to use much browser-specific code. Problem is, as usual, with IE. To achieve best results, write a website for standard-compliant browsers, then add hacks to make it work in IE.
You cannot detect installed applications on client computer, nor launch any of them - beacuse of security. All you can do is to do browser sniffing. You can do it on server side (by examining User-Agent header), or on client side (using JavaScript to check window.navigator object). It is quite complicated and error-prone though and certainly not forward-compatible (future browser versions may confuse your scripts). Moreover, users can change their browser's identification. When you detect unsupported browser, you could display some popup asking user to switch browser.
If you want to detect only IE, you can use IE's conditional comments, which is a most reliable way for detecting IE.
You can't test for Firefox being available nor start it using JavaScript. That would create big security holes...
You can try to figure out if the current browser is Firefox and output a message, although I really hate them (remember that not every visitor will be able to install/use another browser, e.g. within companies or public places).
If it only works on one browser, it isn't a website.
Sometimes we have to rush our work and compromise, but there is a cut-off point where more time is the only sensible option. Making your website multi-browser-compatible is one such example.
However, if you have to detect the user's browser, you could look at quirksmode. Mozilla have good article on browser detection, and the related issues.
A better alternative to browser detection, would be feature detection and Modernizr is very good at this.

Categories

Resources