Introduction to browser plug-in detection and support for custom protocols

Source: Internet
Author: User

Some time ago, I 've been tossing browser plug-in detection and support for custom protocols.

After all kinds of painstaking efforts, we have a simple understanding of this field. Record

 

I. background knowledge
Custom protocols: common protocols include http: // https: // ftp: //

However, we often encounter protocol connections like this.
Thunder: // Thunder's

Item: // iTunes

Ed2k: // of the donkey

Such a protocol requires software installation on the Local Computer and corresponding operations.

That is, when you click a similar connection, the browser will notify the systemProgramProcesses the connection of this protocol, which is achieved through the registry.

References: http://www.cnblogs.com/Aricc/archive/2009/03/18/1415929.html
 

II. Implementation Scheme

To define a custom protocol, you must first have a program corresponding to it,

That is to say, this protocol must be processed by software, which is generally a download operation.

The custom protocol connection is eventually displayed on the web page, which is the interaction between the web page and the local program.

The bridge between them is the browser.

To support a custom protocol, you also need to check whether there is a processing program that supports the Protocol locally.

This capability is determined by detecting the browser plug-ins.

That is, when installing software, add plug-ins to the browser to indicate that the system has the ability to support the Protocol.

 

Draw a flowchart:

Release software and custom protocols-install software and install plug-ins for browsers-use scripts to detect browser plug-ins-click custom protocol connection to call local programs for processing

 

Iii. plugin Detection

You can tryNew activexobject (axname); whether the operation is successful to determine the existence of the plug-in

VaR A = False ;
Try {
VaR OBJ = New Activexobject (axname );
A = True ;
} Catch (E ){
A = False ;
};

ReturnA;

Another method of IE is to pre-embed an object and view its attributes or methods to determine whether the local server can support

For example, the object of Apple iTunes is:<Object classid = "CLSID: D719897A-B07A-4C0C-AEA9-9B663A28DFCB" width = "1" Height = "1" id = "itunesdetectorie"></Object>

 

Firefox Chrome and other browsers can view pluginname compliance by traversing its plugin to determine the existence of the plug-in.

 

VaR A = False ;
If (Navigator. plugins & navigator. plugins. length> 0 ){
For ( VaR B = 0; B <navigator. plugins. length; B ++ ){
VaR C = navigator. plugins [B];
VaR D = C. Name;
If ( New Regexp (plugname, 'I'). Test (D )){
A = True
}
}
}
Return A

 

Another method isMimetype for judgment

 

Try {
VaR Mimetype = navigator. mimetypes ["application/" + plugname];
If (Mimetype ){
A = True ;
} Else {
A = False ;
}
}
Catch (E ){
A = False ;
}
Return A;

 

 

Iv. Existing Problems:

When you operate ActiveX controls on IE, a small yellow bar may appear in the browser. This may be related to your browser settings, and a security prompt may appear, which is unavoidable.

Do not attempt to capture the event that appears in the yellow bar. This is a security prompt, unless the user takes the initiative to operate, other means cannot intervene.

When your plug-in runs under different domain names, the prompt will be repeated. The prompt will disappear only when the user is allowed to run under this domain name.

Of course, if you are willing to spend money, you can make it the same as the iTunes plug-in. By default, it runs under any domain name.

To obtain this permission, you need to talk to Microsoft. This is BD, not Rd.

When the PM says why the sameCodeWhen Apple can do it, but you cannot do it, you can clearly tell them that this is not a technical thing.

 

V. implementation process of specific applications

Go to the page,

Browser judgment

Plug-ins of different browsers support Detection

Cookie record detection results

No plug-in ---- pre-load pop-up window prompts Resources

Monitor click conditions of dedicated protocol connections

Perform relevant operations based on the detection results supported by the plug-in

There are plug-ins ---- call local programs for processing

No plug-in (or cannot be detected) ---- the installation software is prompted in the pop-up window

 

6. Force call

If you are not sure if there is any local program support, what will happen if you force the dedicated link to the browser?

Firefox Chrome has a good prompt interface, prompting the browser not to know which program is used to process the protocol link

Different ie versions have different performance, which is related to their security level.

First, all IE will display an ugly interface, indicating that the browser cannot open the link.

IE6 has the worst security performance. You can use a hidden IFRAME to call this dedicated link without seeing the error message. If you're lucky, you can

Start local program

IE7 8 9 improves security performance. If hidden IFRAME is used to call unrecognized links, no matter how many layers are nested, it will be immediately reflected to the top layer.

It indicates that the link cannot be opened. It is intended to notify the user that you are calling an unrecognized protocol, which may endanger your computer security.

Ie9 will report an error for the first time, indicating that the page cannot be opened, and clicking again will not display the page that cannot be opened again.

 

VII. Project Application and code implementation

 

Http://zhushou.360.cn/script/360mobilemgrdownload.js

 

Example address:

Http://zhushou.360.cn/

 

 

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.