javascript - checking a safari browser for the ability to install an extension -


i'd web page offer browser extension safari users. web page offers extensions google chrome , firefox users.

in chrome, javascript expression typeof chrome.webstore.install !== 'undefined' comes true if it's possible offer user chrome extension.

in firefox, it's typeof installtrigger !== 'undefined'.

is there similar expression return true if it's possible install safari extension?

apple encouraging extension developers submit extensions safari extensions gallery.

if distribute extension own site, install process users suboptimal, , there multiple "trust" dialogs users have consent to.

as far i'm aware, can done own website safari is:

1. detect browser safari.

although browser detection not 100% effective, , feature-based detection preferred, in case can follow effective feature-based detection of chrome , firefox simple, effective test safari (the key being check on navigator.vendor):

var issafari = /apple computer/.test(navigator.vendor) && /safari/.test(navigator.useragent); 

alternatively, can use 1 of more complex browser detection scripts handles minor browsers well.

2. optionally detect version of safari

if need functionality available in specific release of safari, can optionally follow browser version check.

function getsafariversion() {     var index = navigator.useragent.indexof("version");     if (index == -1) return;     return parsefloat(navigator.useragent.substring(index+"version".length+1)); } 

note: if user has altered browser's user-agent, check not accurate.

3. offer .safariextz download, , ask user open it.

link extension bundle, encourage user download it, , provide instructions (and ideally screenshots) of manual install process.

(this 1password on their extension install page.)


bonus:

to handle case users have extension installed, there various methods detect whether safari extension installed website.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -