我有一个类似的脚本:
pagination.js
var busy = false;
jQuery(window).scroll(function () {
if (jQuery(window).scrollTop() > 300) {
jQuery('#scrollUp').stop().animate({
opacity: 0.05
}, 400)
} else {
jQuery('#scrollUp').stop().animate({
opacity: 0.00
}, 400)
}
if (jQuery(window).scrollTop() + jQuery(window).height() > jQuery('#main_content').offset().top + jQuery('#main_content').height() - 50 && !busy) {
busy = true;
link = jQuery('.pagination .nextpage').attr('href');
if (typeof link != 'undefined') {
var params = 'smt_layout=' + jQuery('body').attr('layout') + '&ajaxpage=1';
jQuery.ajax({
type: "POST",
cache: false,
async: false,
data: params,
url: link,
dataType: 'json',
success: function (data) {
if (data != "") {
jQuery('.pagination .nextpage').parent().append('<span class="thispage">Page ' + jQuery('.pagination .nextpage').attr('alt') + '</span>');
jQuery('.pagination .nextpage').remove();
jQuery("#main_content").append(data['content']);
busy = false
}
}
})
}
}
});
jQuery('#scrollUp').live('mouseenter', function () {
jQuery(this).stop().animate({
opacity: 0.1
}, "slow")
}).live('mouseout', function () {
if (jQuery(window).scrollTop() > 300) var o = 0.05;
else var o = 0.00;
jQuery(this).stop().animate({
opacity: o
}, "slow")
});
jQuery('#scrollUp').live('click', function () {
jQuery('html, body').animate({
scrollTop: 0
}, 1200);
});
我在Photonic Gallery Wordpress插件上使用了一个宏弹出框:
,我得到一个错误: Uncaught TypeError:无法读取pagination.js:1上未定义的属性“ top”
它看起来像jQuery冲突吗?您能否让我知道如何解决此问题?预先谢谢你。
答案 0 :(得分:0)
此操作失败:jQuery('#main_content').offset().top
。
请确保:
jQuery(document).ready()
。main_content
的DOM元素。答案 1 :(得分:0)
这是实现脚本的功能:
function headtext() {
if(
(is_archive()&&is_day()&&$this->get( 'seo', 'day' ))||
(is_archive()&&is_month()&&$this->get( 'seo', 'month' ))||
(is_archive()&&is_year()&&$this->get( 'seo', 'year' ))||
(is_category()&&$this->get( 'seo', 'category' ))||
(is_tag()&&$this->get( 'seo', 'tag' ))||
(is_author()&&$this->get( 'seo', 'author' ))||
(is_search()&&$this->get( 'seo', 'search' ))
) {
?><meta name="robots" content="noindex" /><?php
}
if ($this->get( 'general', 'favicon' ))
echo '<link rel="shortcut icon" href="' . $this->get( 'general', 'favicon' ) . '" type="image/x-icon" />' . "\n";
if ($this->get( 'integration', 'rss' )) {
echo '<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="' . $this->get( 'integration', 'rss' ) . '" />' . "\n";
}
if ($this->get( 'layout', 'pagination' )) { ?>
<script type="text/javascript" src="<?php echo get_template_directory_uri()?>/js/pagination.js"></script>
<?php } ?>
<link rel="stylesheet" href="<?php echo get_template_directory_uri()?>/css/wide.css" type="text/css" media="screen and (min-width:1024px)" />
<!--[if lt IE 9]>
<link rel="stylesheet" href="<?php echo get_template_directory_uri()?>/css/wide.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php echo get_template_directory_uri()?>/css/ie.css" type="text/css" media="screen" />
<![endif]-->
<link rel="stylesheet" href="<?php echo get_template_directory_uri()?>/css/mobile.css" type="text/css" media="screen and (min-width:240px) and (max-width:639px)" />
<link rel="stylesheet" href="<?php echo get_template_directory_uri()?>/css/tablet.css" type="text/css" media="screen and (min-width:640px) and (max-width:1023px)" />
<?php if ($this->get( 'integration', 'ecwidcss' )) { ?>
<link rel="stylesheet" href="<?php echo get_template_directory_uri()?>/css/ecwid.css" type="text/css" />
<?php } ?>
<link rel="stylesheet" href="<?php echo get_template_directory_uri()?>/css/shortcode.css" type="text/css" media="screen, projection" />
<script src="<?php echo get_template_directory_uri()?>/js/jquery.cycle.all.js" type="text/javascript"></script>
<?php
if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
?>
<script type="text/javascript">
jQuery(document).ready(function() {
<?php
$this->block_slider_config();
?>
jQuery(".menus .children").addClass('sub-menu');
<?php
$this->block_menu_config("menus");
?>
jQuery('textarea[name="comment"]').each(function(){
jQuery(this).attr('name','<?php echo $_SESSION['commentinput']; ?>');
});
});
</script>
<?php
}