记住Cookie中的位置和大小 [英] Remember position and size in a cookie

查看:137
本文介绍了记住Cookie中的位置和大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道该怎么办.请帮忙.

I have no idea what is to do. Please help.

我建立了一个在页面上可拖动的可缩放项目的网站.你可以在这里看到我所做的... http://www.hagueandhague.co.uk/test/hagueandhague/httpdocs /index.html

I have built a website with draggable scaleable items on a page. You can see what I've done here... http://www.hagueandhague.co.uk/test/hagueandhague/httpdocs/index.html

它使用来自...的Java脚本 http://ajax.googleapis.com/ajax/libs /jqueryui/1.7.2/jquery-ui.js

It uses java script from... http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js

我需要网站做的是记住物品的位置和大小,以便当访客返回网站时,物品就是他们离开它们的地方.

What I need the site to do is remember the position and scale of the items so that when visitors return to the site the items are where they left them.

我相信可以将这些信息存储在cookie中,但是我不知道如何做到这一点或使其起作用.

I believe it is possible to store this information in a cookie, however I have no idea how to do that or make it work.

任何帮助都会很棒,但是如果使用英语/外行,甚至会更好.

Any help would be great, but even better if it's in english/layman's.

谢谢.

詹姆斯.

推荐答案

    <script>
    $(document).ready(function(){
        $('.dragboard').draggable({
            stop: function(event, ui) {
                $.cookie('elementLeft', ui.position.left);
                $.cookie('elementTop', ui.position.top);
            }
        });
        $('.dragboard').css({left : parseInt($.cookie('elementLeft')), top : parseInt($.cookie('elementTop'))});
    });
    </script>

这篇关于记住Cookie中的位置和大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆