Detecting CardSpace support, including FireFox COME FROM: http://www.fearthecowboy.com/2006/12/detecting-cardspace-support-incl

Tuesday, December 12, 2006

Detecting CardSpace support, including FireFox

 

Detecting support for CardSpace, or more importantly information cards in the browser is pretty important, as it would allow the web developer the opportunity to appropriately show the "sign in with your information card" button/link or other text as needed.

The following Javascript will return true if you have support for information cards.

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 ); 

  // Look for IE 7+.
  if( IEVer >= 6 )
  {
    var embed = document.createElement("object");
    embed.setAttribute("type", "application/x-informationcard");

    if(  ""+embed.issuerPolicy != "undefined" )
      return true;
    return false;        
  }    
  // not IE (any version)
  if( IEVer < 0 && navigator.mimeTypes && navigator.mimeTypes.length)
  {
    // check to see if there is a mimeType handler.
    x = navigator.mimeTypes['application/x-informationcard'];
    if (x && x.enabledPlugin)
      return true;

    // check for the IdentitySelector event handler is there.
    var event = document.createEvent("Events");
    event.initEvent("IdentitySelectorAvailable", true, true);
    top.dispatchEvent(event);

    if( top.IdentitySelectorAvailable == true)
      return true;
  }
  return false;
}
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值