如何检测给定浏览器是否具有searchParams
原型为URL
? https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams声明 Chrome 和 FF 可以,但 Edge 没有,但我希望使用 JavaScript 进行检测。
我已经搞乱了isPrototypeOf
,但不认为它适用。
在支持的浏览器中,会有一个URLSearchParams https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams全局对象上可用的构造函数,因此与任何其他全局构造函数一样,
'URLSearchParams' in window
or
typeof window.URLSearchParams === 'function'
类似的也会做。
const support = typeof window.URLSearchParams === 'function';
console.log('supports URLSearchParams API:', support);
var url = new URL('https://stackoverflow.com/questions/47824782/how-to-tell-if-an-object-has-a-given-prototype?support="true"');
if(support){
console.log(url.searchParams.get('support'));
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)