开发者

Saving AJAX page state

开发者 https://www.devze.com 2023-03-13 09:51 出处:网络
Is there any way to listen for hashchanges in the url and log the event for use of a backbutton in AJAX etc.

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

精彩评论

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