在母版页使用jquery的问题
在网上找了几个浮动QQ的代码,在普通页面没有问题,放到母版页就用不了
母版页及浮动QQ
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="RB.MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#floatShow,#floatHide").bind("click", function (e) {
var id = e.target.id, show = id == 'floatShow', cfg = show ? { width: "show", opacity: "show"} : { width: "hide", opacity: "hide" }
, callback = function () { $("#onlineService")[show ? 'show' : 'hide'](); };
$("#onlineService").animate(cfg, "normal", callback);
$("#" + id).hide();
$(show ? '#floatHide' : '#floatShow').show();
return false;
});
});
</script>
<style type="text/css">
*{margin:0;padding:0;list-style-type:none;}
a,img{border:0;}
/* online */
#online_qq_tab a,.onlineMenu h3,.onlineMenu li.tli,.newpage{background:url(images/float_s.gif) no-repeat;}
#onlineService,.onlineMenu,.btmbg{background:url(images/float_bg.gif) no-repeat;}
#online_qq_layer{z-index:9999;position:fixed;right:0px;top:0;margin:150px 0 0 0;}
*html,*html body{background-image:url(about:blank);background-attachment:fixed;}
*html #online_qq_layer{position:absolute;top:expression(eval(document.documentElement.scrollTop));}
#online_qq_tab{width:28px;float:left;margin:120px 0 0 0;position:relative;z-index:9;}
#online_qq_tab a{display:block;height:118px;line-height:999em;overflow:hidden;}
#online_qq_tab a#floatShow{background-position:-30px -374px;}
#online_qq_tab a#floatHide{background-position:0 -374px;}
#onlineService{display:inline;margin-left:-1px;float:left;width:130px;display:none;background-position:0 0;padding:10px 0 0 0;}
.onlineMenu{background-position:-262px 0;background-repeat:repeat-y;padding:0 15px;}
.onlineMenu h3{height:36px;line-height:999em;overflow:hidden;border-bottom:solid 1px #ACE5F9;}
.onlineMenu h3.tQQ{background-position:0 10px;}
.onlineMenu h3.tele{background-position:0 -47px;}
.onlineMenu li{height:36px;line-height:36px;border-bottom:solid 1px #E6E5E4;text-align:center;}
.onlineMenu li.tli{padding:0 0 0 28px;font-size:12px;text-align:left;}
.onlineMenu li.zixun{background-position:0px -131px;}
.onlineMenu li.fufei{background-position:0px -190px;}
.onlineMenu li.phone{background-position:0px -244px;}
.onlineMenu li a.newpage{display:block;height:36px;line-height:999em;overflow:hidden;background-position:5px -100px;}
.onlineMenu li img{margin:8px 0 0 0;}
.onlineMenu li.last{border:0;}
.wyzx{padding:8px 0 0 5px;height:57px;overflow:hidden;background:url(images/webZx_bg.jpg) no-repeat;}
.btmbg{height:12px;overflow:hidden;background-position:-131px 0;}
</style>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div id="online_qq_layer">
<div id="online_qq_tab">
<a id="floatShow" style="display:block;" href="javascript:void(0);">收缩</a>
<a id="floatHide" style="display:none;" href="javascript:void(0);">展开</a>
</div>
<div id="onlineService">
<div class="onlineMenu">
<h3 class="tQQ">QQ在线客服</h3>
<ul>
<li class="tli zixun">在线咨询</li>
<li><a target=blank href=tencent://message/?uin=1014445557&Site=在线客服&Menu=yes><img border=0 SRC="images/pa.gif" alt=[在线客服]></a></li>
<li><a href="#"><img src="images/pa.gif" width="74" height="22" alt="在母版页使用jquery的有关问题" /></a></li>
<li class="tli fufei">付费学员</li>
<li class="last"><a href="#"><img src="images/pa.gif" width="74" height="22" alt="在母版页使用jquery的有关问题" /></a></li>
</ul>
</div>
<div class="wyzx">
<a href="#"><img src="images/right_float_web.png" width="122" height="50" alt="在母版页使用jquery的有关问题" /></a>
</div>
<div class="onlineMenu">
<h3 class="tele">QQ在线客服</h3>
<ul>
<li class="tli phone">4008-517-517</li>
<li class="last"><a class="newpage" href="#">新版调查</a></li>
</ul>
</div>
<div class="btmbg"></div>
</div>
</div>
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="clearfloat"></div>
<div> </div>
</form>
</body>
</html>
是否和你调用的页面在同一文件夹下?
[解决办法]
<script?type="text/javascript"?src="jquery.js"></script>你这个是jqery的min包吗?
其次服务器控件ID
$("#<%=TxtName.ClientID %>").val()
<a id="floatShow" class="floatShow" style="display:block;" href="javascript:void(0);">收缩</a>
<a id="floatHide" class="floatHide" style="display:none;" href="javascript:void(0);">展开</a>
$(".floatShow,.floatHide").bind("click", function (e) {
//....
});