直接链接到扩展的jQuery摘要框

时间:2012-12-19 16:32:20

标签: jquery html expander

我正在使用Karl Swedberg(http://jjnursingnotes.com/DEC12/jquery.summarize.js)的摘要jQuery插件来包含简报文章(http://jjnursingnotes.com/DEC12/),并希望从外部链接到这些文章。简单地为元素提供链接名称#001不起作用,因为我希望在单击链接时自动展开该框。

目前,我使用的链接如下所示:

<a href="http://jjnursingnotes.com/DEC12?section=01">

... div层看起来像这样:

<div class="expandable" id="sect01">

...我正在使用的javascript看起来像这样:

<script type="text/javascript">
    // Redirect to Appropriate Section
    var urlParams = {};
    (function() {
        var match,
        pl     = /\+/g,  // Regex for replacing addition symbol with a space
        search = /([^&=]+)=?([^&]*)/g,
        decode = function(s) { return decodeURIComponent(s.replace(pl, " ")); },
        query  = window.location.search.substring(1);

        while(match = search.exec(query))
            urlParams[decode(match[1])] = decode(match[2]);
    })();

    $(document).ready(function() {
        if(urlParams['section'] != '') {
            $("#sect" + urlParams['section']).find(".read-more a").click();
            $('body,html').animate({scrollTop: $("#sect" + urlParams['section']).offset().top}, 500);
        }
    });
</script>

问题是,这根本不起作用,我不知道为什么!有什么想法吗?

谢谢!

0 个答案:

没有答案
相关问题