3 <title>Protocol Handler Test - Register
</title>
4 <script type=
"text/javascript">
5 function registerCustomHandler() {
6 var custom_protocol
= "web+search";
7 var query_value
= custom_protocol
+ ":test";
9 var url
= document
.URL
+ "?" + query_key
+ "=%s";
10 var title
= "Example Search";
12 navigator
.registerProtocolHandler(
13 custom_protocol
, url
, title
);
14 var element
= document
.getElementById('test_protocol');
15 element
.innerText
= query_value
;
16 element
.setAttribute('href', query_value
);
18 return {"protocol": custom_protocol
, "url": url
, "title": title
,
19 "query_key": query_key
, "query_value": query_value
};
22 function registerMailClient() {
23 var mail_protocol
= "mailto";
24 var query_value
= mail_protocol
+ ":example@examplemail.com";
25 var query_key
= "source";
26 var url
= document
.URL
+ "?" + query_key
+ "=%s";
27 var title
= "ExampleMailClient";
29 navigator
.registerProtocolHandler(mail_protocol
, url
, title
);
30 return {"protocol": mail_protocol
, "url": url
, "title": title
,
31 "query_key": query_key
, "query_value": query_value
};
34 // Analyzes the query substring (if any) of the URL and confirms
35 // whether it's expected.
36 function doesQueryConformsToProtocol(query_key
, query_value
) {
37 var query
= window
.location
.search
.substring(1);
38 var arg_list
= query
.split("&");
40 if(arg_list
.length
!= 1) return false;
41 var variable_value
= arg_list
[0].split("=");
42 if((variable_value
[0] != query_key
) ||
43 (unescape(variable_value
[1]) != query_value
))
51 <a id=
"test_protocol"></a>
54 <a id=
"test_mail_protocol" href=
"mailto:example@examplemail.com">mailto:example@examplemail.com
</a>