标签: modernizr

4
推荐指数
1
解决办法
1880
查看次数

YepNope(Modernizr)和Google Analytics

我使用伟大的异步脚本加载器yepnope.js(在Modernizr2中).

我的问题是,将latset Google Analtics异步代码合并到yepnope(如果有的话)的最佳方法是什么?

谷歌建议使用实际的分析代码:

<html>

<head>
  <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXX-X']);
    _gaq.push(['_trackPageview']);
  </script>
</head>

<body>
  <p>Page Content</p>

  <script src="some_random_script.js"></script>

  <p>Page Content</p>

  <script type="text/javascript">  (function() {
    var ga = document.createElement('script');     ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:'   == document.location.protocol ? 'https://ssl'   : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
   </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

但在Modernizrs文档中,他们提到了这一点:

// Give Modernizr.load a string, an object, or an array of strings and objects
Modernizr.load([
  // Presentational …
Run Code Online (Sandbox Code Playgroud)

google-analytics modernizr yepnope

4
推荐指数
1
解决办法
2267
查看次数

为什么Modernizr不为我工作?

我不认为modernizr喜欢我,有人可以告诉我我做错了什么.我似乎无法使用现代化的firefox,即等...我只使用页眉,页脚和导航等元素...

这是我的代码:

<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie ie6 lte9 lte8 lte7 no-js"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie ie7 lte9 lte8 lte7 no-js"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie ie8 lte9 lte8 no-js"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie ie9 lte9 no-js"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class="notie no-js"> <!--<![endif]-->
  <head>
    <title></title>
    <meta name="description" content="" />
    <link href="css/main.css" rel="stylesheet" type="text/css" /> 

    <script src="modernizr-2.0.6.min.js"></script>

    <script type="text/javascript" src="http://use.typekit.com/kmy1sfb.js"></script>
    <script type="text/javascript">try{Typekit.load();}catch(e){}</script>

  </head>
Run Code Online (Sandbox Code Playgroud)

检查firebug它输出正常,我得到我应该的所有元素但没有任何元素正在工作...

例如,如果我在firebug中单击标题并将CSS高度编辑为5000px它不会移动,对齐等也不正确.

html html5 css3 modernizr

4
推荐指数
1
解决办法
1万
查看次数

Modernizr检查以检测Firefox

使用modernizr可以检查firefox功能有哪些可能的检查?

javascript modernizr

4
推荐指数
2
解决办法
1万
查看次数

4
推荐指数
1
解决办法
144
查看次数

平板电脑的方向改变与jquery和modernizr

所以我有一个导航菜单,可以在纵向或横向观看平板电脑时改变风格.它将最后几个菜单项折叠到另一个下拉菜单中.然而,菜单不会在方向更改时更新,仅在刷新后才会更新.

Jquery Modernizr代码:

if(Modernizr.mq('(max-device-width: 800px) and (orientation: portrait)')){
    // portrait stuff
        // unhides last few menu items
        $('#menu-primary-items > li:nth-last-child(-n+3)').css('display', 'block');

        // remove hide and first child class originally assigned to it from it's ul parent
        // then add the more list item to the end of the nav menu
        $('.moreItem').removeClass('hide first-child').appendTo('#menu-primary-items');

        // grab the last two items of the nav menu and insert into the more list item menu
        $('.topNavigation .toplevel').slice(-2).appendTo('.moreMenu');
    } 
Run Code Online (Sandbox Code Playgroud)

有什么建议??

jquery media-queries modernizr

4
推荐指数
1
解决办法
5247
查看次数

为什么在Internet Explorer中访问localStorage对象会抛出错误?

我正在处理客户端问题,其中Modernizr意外地检测不到localStorageInternet Explorer 9中对象的支持.我的页面正确使用HTML 5 doctype(<!DOCTYPE html>)和开发人员工具报告页面具有IE9的浏览器模式和文档IE9标准的模式,所以我希望这个工作.

我已调试到Modernizr中的以下try/ catch块,并发现一旦localStorage访问该对象就会抛出JavaScript错误.

tests['localstorage'] = function() {
    try {
        localStorage.setItem(mod, mod);
        localStorage.removeItem(mod);
        return true;
    } catch(e) {
        return false;
    }
};
Run Code Online (Sandbox Code Playgroud)

在某些机器上,JavaScript错误的消息是The system cannot find the file specified..在其他情况下它只是Invalid argument.和Internet Explorer阻止错误前5分钟.

是什么导致访问该localStorage对象在Internet Explorer上抛出错误?

javascript internet-explorer local-storage modernizr

4
推荐指数
1
解决办法
2997
查看次数

似乎无法获得jquery resize事件来处理Modernizr媒体查询功能

我正在尝试在以下函数上激活resize事件:

$(function() {
if (Modernizr.mq('only screen and (min-width: 1140px)')) {
$('div#ss1').html('<div>[snip]</div>');
$('div#ss1').append('<div><gcse:searchbox-only></gcse:searchbox-only></div>');
  } 
if (Modernizr.mq('only screen and (max-width: 1139px)')) {
$('div#ss2').html('<div>[snip]</div>');
$('div#ss2').append('<div><gcse:searchbox-only></gcse:searchbox-only></div>');
  } 
});
Run Code Online (Sandbox Code Playgroud)

我想为它添加一个resize监听器.基于http://api.jquery.com/resize/我将第一行更改为$(window).resize(function()但后来整个功能停止工作.

我究竟做错了什么?谢谢.

更新:根据Paul Irish的帖子,我将smartresize添加到我的plugins.js.我从改变函数调用$(function()$(window).smartresize(function()和它停止工作.将其更改回$(function()并再次起作用.为什么我不能向这个吸盘添加任何类型的resize事件监听器?:-)

jquery resize modernizr

4
推荐指数
1
解决办法
2532
查看次数

如何检测浏览器是否支持CSS3模糊?

我正在尝试在JS中编写一些东西,它允许我告诉用户的浏览器是否支持CSS3 blur,并根据需要显示(或不显示)元素.它看起来不像Modernizr支持它,我真的想不出另一种方法来检查它.我怎样才能做到这一点?

javascript css css3 modernizr

4
推荐指数
1
解决办法
1559
查看次数

在mordernizr中有什么javascript模式?

我刚刚去了http://modernizr.com/downloads/modernizr-latest.js

并遇到了228号线

_hasOwnProperty = ({}).hasOwnProperty, hasOwnProp;
Run Code Online (Sandbox Code Playgroud)

谁有人能告诉我这条线的含义?

javascript design-patterns modernizr

4
推荐指数
1
解决办法
43
查看次数