modernizr

Load external Google Fonts stylesheet with YepNope/Modernizr

耗尽温柔 提交于 2019-12-21 22:05:17
问题 I'm trying to load a dynamically generated Google Font stylesheet using Modernizr (YepNope) but always get this error: Uncaught SyntaxError: Unexpected token ILLEGAL (css:1) My stylesheet looks like this: http://fonts.googleapis.com/css?family=Holtwood+One+SC and I'm calling it via Modernizr.load({ load: ['css!http://fonts.googleapis.com/cssfamily=Holtwood+One+SC|Terminal+Dosis:700'], callback: function (url, result, key) { console.log('loaded...!'); } }); The website says this but for some

Modernizr just for one quick check?

心不动则不痛 提交于 2019-12-21 09:26:11
问题 I want to check if the browser who's running my page is capable of handling the 'html 5 placeholder' I know I can add the following javascript check: !Modernizr.input.placeholder but is it worth to import a library just for one check ? also how does modernizr do that for me (i mean how is it implemented under the cover) ? 回答1: If you want to check for placeholder support, then all you need to do is; var placeholderSupport = "placeholder" in document.createElement("input"); And to answer your

Angular 2: Check whether user's browser is compatible

℡╲_俬逩灬. 提交于 2019-12-20 17:28:09
问题 I'm writing an Angular 2 app but am conscious that some users may not be using a browser that can support Angular 2. I have a check for whether Javascript is enabled, I am more interested in whether the user's browser doesn't support certain JS/HTML5/other features required by Angular 2. What would be the best way to assess whether the user's browser supports Angular 2, and display a message if not? I'm aware of e.g. Modernizer, but not sure where to begin as Modernizer's focus seems to be on

Angular 2: Check whether user's browser is compatible

谁说我不能喝 提交于 2019-12-20 17:27:32
问题 I'm writing an Angular 2 app but am conscious that some users may not be using a browser that can support Angular 2. I have a check for whether Javascript is enabled, I am more interested in whether the user's browser doesn't support certain JS/HTML5/other features required by Angular 2. What would be the best way to assess whether the user's browser supports Angular 2, and display a message if not? I'm aware of e.g. Modernizer, but not sure where to begin as Modernizer's focus seems to be on

Can you detect if Cleartype is enabled on PC via javascript?

邮差的信 提交于 2019-12-20 12:31:04
问题 Some @font-face fonts don't play nice with non-cleartype settings (gets really choppy on the edges) Is there a way to detect this via javascript so that I can do a modernizr-style class addition to the body if cleartype is off so I can use this in my CSS 回答1: In IE 6+ you can check the screen.fontSmoothingEnabled property. Otherwise you need to use an html 5 canvas to check for this. Details here. 来源: https://stackoverflow.com/questions/4328558/can-you-detect-if-cleartype-is-enabled-on-pc-via

A better test for base64 URI support (can I create a large base64-encoded image in JS?)

こ雲淡風輕ζ 提交于 2019-12-19 03:21:44
问题 I'm using Modernizr to detect the features supported in the browser our users are running, so far so good. But I've come up against a theoretical problem when testing for base64 compatibility. The patch for this support is detailed here, and works- except for a weird case with IE8- it only allows base64 encoded images of up to 32KB. I don't really want to embed a 32KB long base64 string inside my JS file, it'll add a crazy amount of bloat. So, could I create a 32KB- valid- image using JS? I'm

JavaScript function with 'undefined' parameter [duplicate]

不问归期 提交于 2019-12-17 09:40:56
问题 This question already has answers here : What advantages does using (function(window, document, undefined) { … })(window, document) confer? [duplicate] (4 answers) Closed 4 years ago . Going around Modernizr source code I have found strange thing: window.Modernizr = (function(window,document,undefined) { After that this function will be called with two arguments ( this, this.document ). Why undefined is used here? Is it meaningful or it's just strange code-style? 回答1: Creates a local

easy html5 - HTML5特性检测

烈酒焚心 提交于 2019-12-17 08:06:13
HTML5是一些新的独立特性的集合,因此我们不能检测浏览器是否支持“HTML5”,但是我们可以分别检测浏览器是否支持诸如“画布(canvas)”、“视频(video)”、“地理位置(geolocation)”等特性 简介 做web前段开发人员已经习惯了处理多浏览器兼容(如IE、firefox、chrome)、多浏览器版本兼容(Ie6、ie7、ie8、ie9),我们需呀从js和css上考虑让它如何兼容,如何一致;HTML5也一样,只是它更广泛的被浏览器开发商接受并兼容,而且效果良好;但是这里仍旧有一个问题,就是“有些老的浏览器不支持” :(;你把html5用的炉火纯青,忽然来个ie6用户;所以我们需要对浏览器对html5的支持做一定的检测,从而给用户以有好提示; 怎么检测 当浏览器在渲染web页面的时候会构造一个文档对象模型(DOM),通过它来表示页面上的HTML元素,任何一个tag都会被表示为一个对象;当然也有windwos和document这些不和特定页面元素绑定在一起的全局对象; 所有的dom对象都共享一些属性,但是有些对象会拥有特定的属性。在支持HTML5特性的浏览器中,特性相关的dom对象就会有特定的属性。通过这些特定的属性,我们可以快速的检测出那些html5特性是被支持的。比如常见的四种方法: 1.检测全局对象(如window,navigator)是否拥有特定的属性

Feature detection for CSS3 transition property

杀马特。学长 韩版系。学妹 提交于 2019-12-14 03:48:58
问题 I was just messing around this modernizr to find out, how do they check if a certain CSS property is supported in a user's browser, basically I just wanted to have a small script that told me if the user's browser supports CSS transitions. I abstracted the modernizr code to something like below: Elem = document.createElement('Alx'); eStyle = Elem.style; var cssProp = (function check(){ props = ["transition", "WebkitTransition", "MozTransition", "OTransition", "msTransition"]; for(var i in

使用Google托管jQuery的最佳方法,但在Google上使用我的托管库失败

谁说我不能喝 提交于 2019-12-13 17:46:48
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 什么是尝试 在Google (或其他Google托管库)上加载 托管jQuery ,但如果Google尝试失败则加载我的jQuery副本的好方法? 我并不是说Google很脆弱。 在某些情况下,Google副本被阻止(例如,显然在伊朗)。 我会设置一个计时器并检查jQuery对象吗? 两份复印件通过的危险是什么? 并非真正在寻找诸如“仅使用Google一个”或“仅使用您自己的一个”之类的答案。 我理解那些论点。 我也了解用户很可能已经缓存了Google版本。 我通常在考虑云的回退。 编辑:这部分添加... 由于Google建议使用google.load加载ajax库,并且完成后会执行回调,所以我想知道这是否是序列化此问题的关键。 我知道这听起来有点疯狂。 我只是想弄清楚它是否可以可靠地完成。 更新:jQuery现在托管在Microsoft的CDN上。 http://www.asp.net/ajax/cdn/ #1楼 您可以这样实现: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> <script> window.jQuery || document.write('<script