Skip to content

Instantly share code, notes, and snippets.

@naoyeye
Created February 12, 2015 08:34
Show Gist options
  • Select an option

  • Save naoyeye/92c61ac33ef238c78756 to your computer and use it in GitHub Desktop.

Select an option

Save naoyeye/92c61ac33ef238c78756 to your computer and use it in GitHub Desktop.
判断是不是在淘宝中、是不是在虾米中、是不是在微博中、是不是在微信中
var j = window.navigator.userAgent;
var g = {
android: j.match(/(Android);?[\s\/]+([\d.]+)?/),
iphone: j.match(/(iPhone\sOS)\s([\d_]+)/)
};
var d = {
aliapp: j.match(/\AliApp\(([^\/]+)\/([\d\.\w]+)\)/),
xiami: j.match(/(AliApp)\((XM)\/([0-9.]+)\)*/),
weibo: j.match(/.*?(weibo\_\_([0-9.]+))\s*/),
weixin: j.match(/.*?(MicroMessenger\/([0-9.]+))\s*/)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment