0

我是一个新手,所以如果这个脚本是初级的,请原谅。

我正在尝试使用 jQuery 的 .load() 函数在我构建的表达式引擎站点上加载事件日历的下个月或上个月。以下脚本在 Chrome、Safari、IE 和 Firefox 4 beta 中有效,但在 FF 3.6.10 中失败:

   $('th a.right, th a.left, th a.center').click(function() {
      var navMonth = $(this).attr("title");
      $('#calendar').html('<p style="padding: 102px 120px;"><img src="http://dashboardco-op.org/images/infra/ajax-loader.gif" /></p>');
      $('#calendar').load(navMonth);

});

这是html:

              <th colspan="1"><a id="mc_prev_month" class="icon left" title="{path='live/calendar'}{prev_month format="%Y/%m"}/">&larr;</a></th>
              <th colspan="5"><a class="center" title="{path='live/calendar'}{next_month format="%Y/%m"}/">{month format="%F %Y"}</a></th>
              <th colspan="1"><a id="mc_next_month" class="icon right" title="{path='live/calendar'}{next_month format="%Y/%m"}/">&rarr;</a></th>

我正在使用“title”属性,因为 .load() 不会覆盖“href”——因此页面加载到新页面中而不是异步加载。

谢谢。

4

1 回答 1

0

不知道为什么它可能与特定的浏览器有问题,但我确实认为有一种更清洁的方法来做你想做的事情。看一下jQuery中这个函数取消锚点点击时打开新页面:preventDefault()

有了这个,您可以将路径放在 href 标记中,如果没有其他原因可能会使标记看起来更清晰。除此之外,唯一想到的其他事情可能是锚需要 href 属性(我不认为是这种情况?)或者 FF 3.6 以不同的方式处理 title 属性?

于 2010-11-03T04:27:33.760 回答