Detecting Information Card Support (CardSpace!) in a browser
I hacked out this a few weeks back, and never got around to publishing it. I've not decided that this is the 'official' way to detect Information Card support in a browser, but it'll do until I can think of something better.
I'd say something like, "see how it detects support in other browsers too?" except that I'm not thinking many people have a CardSpace plugin for another browser yet. But you can trust me--It works!
<html>
<head>
<SCRIPT LANGUAGE="Javascript">
function AreCardsSupported () { var IEVer = - 1 ; if ( navigator . appName == 'Microsoft Internet Explorer' ) if ( new RegExp ( "MSIE ([0-9]{1,}[\.0-9]{0,})" ) . exec ( navigator . userAgent ) != null ) IEVer = parseFloat ( RegExp . $1 );
if ( IEVer >= 6 ) { var embed = document . createElement ( "object" ); embed . setAttribute ( "type" , "application/x-informationcard" ); if ( "" + embed . issuerPolicy != "undefined" ) return true ; return false ; } if ( IEVer < 0 && navigator . mimeTypes && navigator . mimeTypes . length ) { x = navigator . mimeTypes [ 'application/x-informationcard' ]; if ( x && x . enabledPlugin ) return true ; } return false ; } function ShowDetection () { if ( AreCardsSupported () ) alert ( "Information Cards are supported by this browser :D" ); else alert ( "Information Cards are NOT supported by this browser :(" ); } |
</SCRIPT>
<body onload="ShowDetection()">
</body>
</head>
g
Garrett Serack | Program Manager | Connected Identity and Directory| Microsoft Corporationblog: https://blogs.msdn.com/garretts
Comments
- Anonymous
August 04, 2006
Garrett shares some of his JS-flavoured wizardry: with that snippet you can&nbsp;find out&nbsp;on the...