0

我正在使用 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>

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

谢谢!

4

0 回答 0