下面是用javascript写的函数。在IE下能够实现,但在火狐和其他非IE内核的不能兼容。
听说jquery能兼容各个浏览器版本。所以想叫大家帮我改写,用jquery写。谢谢了。
function show() {
document.getElementById("Imgdetail").style.display = "block";
document.getElementById("Imgdetail").style.left = event.clientX + document.body.scrollLeft;
document.getElementById("Imgdetail").style.top = event.clientY + document.body.scrollTop;
}
function hid() {
document.getElementById("Imgdetail").style.display = "none";
}
</script>
听说jquery能兼容各个浏览器版本。所以想叫大家帮我改写,用jquery写。谢谢了。
function show() {
document.getElementById("Imgdetail").style.display = "block";
document.getElementById("Imgdetail").style.left = event.clientX + document.body.scrollLeft;
document.getElementById("Imgdetail").style.top = event.clientY + document.body.scrollTop;
}
function hid() {
document.getElementById("Imgdetail").style.display = "none";
}
</script>
function getEvent(){
return window.event||arguments.callee.caller.arguments[0];
}将你的event换成getEvent()即可
$("#Imgdetail").css('left','');
$("#Imgdetail").css('top','');
var left = e.pageX;
var top = e.pageY;
$("#Imgdetail").css({display: 'block', left: left, top: top});
}
function hid() {
$("#Imgdetail").css("display", "none");
}
//事件监听这样加
$(document.body).click = show;
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton linkdetials = e.Row.FindControl("LBDetials") as LinkButton;
if (linkdetials != null)
{
linkdetials.CommandArgument = e.Row.RowIndex.ToString(); linkdetials.Attributes.Add("onmouseover", "show()");
linkdetials.Attributes.Add("onmouseout", "hid()");
}
}
}定义监听的,怎么改 在。
jquery
function show(event) {
event = event || window.event;
$("#Imgdetail").css({"display": "block", left: Number(event.clientX) + Number($("body").scrollLeft()), top: Number(event.clientY) + Number($("body").scrollTop())});
}function hide() {
$("#Imgdetail").css("display", "none");
}
linkdetials.Attributes.Add("onmouseover", "show()");
linkdetials.Attributes.Add("onmouseout", "hid()");改成
linkdetials.Attributes.Add("onmouseover", "show(e)");
linkdetials.Attributes.Add("onmouseout", "hid(e)");
linkdetials.Attributes.Add("onmouseover", "show("+e+")");
linkdetials.Attributes.Add("onmouseout", "hid("+e+")");