English 中文(简体)
页: 1 装上载体和与 co合器的树脂
原标题:jQuery onload and resize with cookie set

寻求帮助,以补充我已经做的工作。 我的工作是把 s塞改成一个特定类别,改变不同决议的网格。 我需要的是一个 co子,这样,电网在从网页上到网页时仍然保持持久性。

    // swaps the grid span names when the resolution goes below 1200px
    // or when page is loaded below 1200px

     $(window).bind("load resize", function(){

        var width = $(window).width(),
        bodycontent_grid = width < 1200 ?  span8  :
                    width > 1200 ?  span6  :   ;
         rightcol_grid = width < 1200 ?  span3  :
                    width > 1200 ?  span5  :   ;

        $( .bodycontent ).removeClass( span6 span8 ).addClass(bodycontent_grid),
        $( .rightcol ).removeClass( span3 span5 ).addClass(rightcol_grid);
    });
问题回答

以联合材料为基础的解决办法(已经就绪)并不好,但我会试图首先回答有关 co的问题:

You could use some kind of jQuery cookie plugin or just plain JS which is a bit harder. jQuery syntax is:

$.cookie( name ,  value ); // storing cookie
$.cookie( name ); // reading cookie

你们可以把你的来源代码改成这样的内容:

function resizeContainer(var force=false) // additional parameter is used to force resetting cookie
{
    var width;
    if($.cookie( knownWidth ) && !force) // if there s a cookie and we re not forcing reset, use width from cookie
    {
        width = $.cookie( knownWidth );
    }
    else
    {
        width = $(window).width();
        $.cookie( knownWidth , width);
    }
    var bodycontent_grid = width < 1200 ?  span8  :
                width > 1200 ?  span6  :   ;
     rightcol_grid = width < 1200 ?  span3  :
                width > 1200 ?  span5  :   ;

    $( .bodycontent ).removeClass( span6 span8 ).addClass(bodycontent_grid),
    $( .rightcol ).removeClass( span3 span5 ).addClass(rightcol_grid);
}

$(window).bind("load", function(){
    resizeContainer(); // onload use cookie
});
$(window).bind("resize", function(){
    resizeContainer(true); // when resizing force changing the cookie
});

在信使中,可以进入服务器一侧的厨师,然后可以在服务器一侧用 app子生成集装箱。

www.un.org/spanish/ecosoc 我必须说,我不喜欢用厨师解决问题。 关于,因此,为什么不使用CSS ?

你可以在你档案中这样做:

@media only screen and (min-width : 1200px) {
    /* Styles when over 1200px */
}

@media only screen and (max-width: 1199px) {
    /* Styles when under 1200px */
}

顺便提一下,将浏览器窗户转至: 它纯属国家安全局!





相关问题
How to suppress/remove PHP session cookie

I need to suppress an already set session cookie header, but I cannot find any way to do this. Why? I need to make an image, sent by a PHP script, cacheable by the end user; this image is used to ...

Remove Cookies from JS or CSS files

Bizarrely my javascript and css files have cookies (says Firebug). I use Zend Framework and I think it has to do with it. Could I change the .htaccess that CSS or JS files don t link to the ZF or is ...

httplib2, how to set more than one cookie?

As you are probably aware, more often than not, an HTTP server will send more than just a session_id cookie; however, httplib2 handles cookies with a dictionary, like this: response, content = http....

cookies control

what tool wold you recommend me to use in order to see what data are stored in my cookies while i m browsing the net. I m a beginner into webdev field(6 months php experience) and i m curious to see ...

热门标签