本文实例讲述了WordPress添加前往顶部成果的办法。分享给大家供大家参考。详细完成办法如下:
前往顶部成果不是WordPress自带的性能,这是一款js或jquery的成果,这里就来给大家引见在WordPress中添加反回顶部成果的办法.
**步:在上面主题文件footer.php底下加上这段代码:
<script src="top.js" type="text/javascript" charset="utf-8"></script >  
<p id="scroll"><a href="javascript:void(0)" onclick="goto_top()" title="前往顶部">TOP</a></p>//<![CDATA[  
var goto_top_type = -1;  
var goto_top_itv = 0;  
function goto_top_timer()  
{  
var y = goto_top_type == 1 ? document.documentElement.scrollTop : document.body.scrollTop;  
var moveby = 15;  
y -= Math.ceil(y * moveby / 100);  
if (y < 0) {  
y = 0;  
}  
if (goto_top_type == 1) {  
document.documentElement.scrollTop = y;  
}  
else {  
document.body.scrollTop = y;  
}  
if (y == 0) {  
clearInterval(goto_top_itv);  
goto_top_itv = 0;  
}  
}  
function goto_top()  
{  
if (goto_top_itv == 0) {  
if (document.documentElement && document.documentElement.scrollTop) {  
goto_top_type = 1;  
}  
else if (document.body && document.body.scrollTop) {  
goto_top_type = 2;  
}  
else {  
goto_top_type = 0;  
}  
if (goto_top_type > 0) {  
goto_top_itv = setInterval('goto_top_timer()', 50);  
}  
}  
}  
//]]>/*前往顶部*/  
#scroll {display:block; width:30px; margin-right:-380px;  
position:fixed;  
right:50%;  
top:90%;  
_margin-right:-507px;  
_position:absolute;  
_margin-top:30px;  
_top:expression(eval(document.documentElement.scrollTop));  
}  
#scroll a {  
display:block;  
float:right;  
padding:9px 5px;  
cursor: pointer;  
background-color:#444;  
color:#fff;  
border-radius:5px;  
text-decoration: none;  
font-weight:bold;  
}  
#scroll a:hover {  
background-color:#333;  
color:#669900;  
text-decoration: none;  
font-weight:bold;  
}心愿本文所述对大家的WordPress建站有所协助。
以上就是安达网络工作室关于《WordPress增加返回顶部效果的方法》的一些看法。更多内容请查看本栏目更多内容!
本文实例讲述了WordPress疾速增加友谊链接性能的办法。分享给大家供大家参考。详细办法剖析如下: WordPres...
函数意义 wp_nav_menu () 自定义菜单显示函数 register_nav_menu () 自定义菜单注册函数 – 复数 register_...
共性化登陆界面的办法有两种,第一种是交换登陆背景,这个算是小型共性化吧: 在/wp-admin/images找到login...
编写WordPress插件和主题的时分,常常需求用到cookie,比方存取用户形态等,我之前编写的插件Ludou Simple ...
明天偶尔留意到WordPress的分类和标签隐没了,开端认为是数据库表损坏,于是经过PHPMyAdmin修复表,然而留意...
上面是详细处理流程:1 首先关上phpadmin,从右边的表中抉择xx_opition2 在xx_opition中进行查问,在查问框...