开发者

Saving AJAX page state

Is there any way to listen for hashchanges in the url and log the event for use of a backbutton in AJAX etc.

Using links like such:

<a href="/#!page">Go to page!</a>

and script like this:

<script type="text/javascript">

    $(function () {
        if (window.location.hash){contentload(window.location.hash);}

        $('a').click(function() {
            fragment = this.hash;
            contentload(fragment);
        });

    });

    function contentload(fragment) 开发者_StackOverflow社区{
        fragment = fragment.slice(1).replace('!', '')
        $('#content').load('http://mysite.com/'+fragment+'?ajax=1');
    }

</script>

I need to try and save the state of the page, Ive seen the jQuery address plugin but have no idea how to implement this..


take a look at this jquery plugin http://benalman.com/projects/jquery-bbq-plugin/


i solved this using the jQuery Address plugin

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜