我在我的Wordpress网站上使用此插件:http://wordpress.org/plugins/wordpress-sliding-drawer-content-area/,为我的小部件创建一个抽屉。它在我的本地服务器上运行得非常好。
不幸的是,我必须将每个Wordpress页面转换为HTML页面,以便在我的客户端的Intranet服务器上使用。那是抽屉拒绝在页面加载时保持关闭的时间。与之前不同。
这是js:
jQuery(document).ready(function() {
if(jQuery('#sod-drawer-plugin.left').length >0){
var $handle = jQuery('#sod-drawer-plugin.left #sod-drawer-handle');
var $plugin = jQuery('#sod-drawer-plugin.left');
var $adjustment = (parseInt($handle.outerWidth())/2)-parseInt($handle.outerHeight())/2;
if (jQuery.browser.msie){
$plugin.css({
left:parseInt($plugin.css('left'),10) == 0 ? -$plugin.outerWidth():0
});
$handle.css({
left:parseInt($plugin.css('left'),10) == 0 ? parseInt($plugin.outerWidth()-$adjustment):$plugin.outerWidth()
});
$handle.click(function(){
$plugin.animate({
left:parseInt($plugin.css('left'),10) == 0 ? -$plugin.outerWidth():0
});
$handle.animate({
left:parseInt($plugin.css('left'),10) == 0 ? parseInt($plugin.outerWidth()-$adjustment):$plugin.outerWidth()
});
});
}else{
$plugin.css({
left:parseInt($plugin.css('left'),10) == 0 ? -$plugin.outerWidth():0
});
$handle.css({
left:parseInt($plugin.css('left'),10) == 0 ? parseInt($plugin.outerWidth()-$adjustment):$plugin.outerWidth()-$adjustment
});
$handle.click(function(){
$plugin.animate({
left:parseInt($plugin.css('left'),10) == 0 ? -$plugin.outerWidth():0
});
$handle.animate({
left:parseInt($plugin.css('left'),10) == 0 ? parseInt($plugin.outerWidth()-$adjustment):$plugin.outerWidth()-$adjustment
});
});
}
}
});
HTML:
<!DOCTYPE html>
<!-- saved from url=(0088)./work-life-balance/enhance-your-professional-standing/ -->
<html lang="en-US"><!--<![endif]--><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title>Enhance Your Professional Standing | Staff Benefits and Work-life Initiatives</title>
<link rel="stylesheet" id="sod_drawer_css-css" href="./style(1).css" type="text/css" media="all">
<script type="text/javascript" src="./jquery.js"></script>
<script type="text/javascript" src="./sod_drawer.js"></script>
<link rel="stylesheet" type="text/css" href="./saved_resource.css">
<link rel="stylesheet" type="text/css" media="all" href="./style.css">
</head>
<body class="page page-id-167 page-child parent-pageid-4 page-template-default">
<div class="sod-drawer left" id="sod-drawer-plugin" style="left: -280px;"> <!--- This value changes to left:0px when loaded on the browser --->
<div id="sod-drawer-handle" class="pull black rotate" style="left: 240px;">
<div class="tag"><p>Contents</p></div>
</div>
<div class="content">
<div class="sod-drawer-inner">
<div class="full" id="sod-drawer-1">
<div id="execphp-2" class="sod-drawer-widget widget_execphp">
<div class="execphpwidget">
<div id="sidebar">
<h1><a href="./" title="Staff Benefits and Work-life Initiatives" rel="home">Staff Benefits and Work-life Initiatives</a></h1>
<div id="access" role="navigation" class="desc">
<div class="menu-main-menu-container">
<ul id="menu-main-menu" class="menu">
<li id="menu-item-33" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-33"><a href="./">Introduction</a>
</li>
<li id="menu-item-626" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-626"><a href="./epilogue/">Epilogue</a></li>
</ul>
</div>
</div><!-- #access -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
我不熟悉Javascript,所以我会非常感激一点解释:)
答案 0 :(得分:0)
jQuery脚本库是否正确加载?我怀疑文档头部脚本的src URL:
<script type="text/javascript" src="./jquery.js"></script>
这些网址可能是个问题。它可以在您的本地服务器中正常工作,但不能在实时URL上正常工作。您可能需要将其更改为“/jquery.js”,因为“。”指的是当前目录。开头的“/”右侧是指根URL。
<script type="text/javascript" src="/jquery.js"></script>
请尝试一下,让我知道结果。