/**
* 指定位置顯示$.messager.show
* options $.messager.show的options
* param = {left,top,right,bottom}
*/
$.extend($.messager, {
showBySite : function(options,param) {
var site = $.extend( {
left : "",
top : "",
right : 0,
bottom : -document.body.scrollTop
- document.documentElement.scrollTop
}, param || {});
var win = $("body > div .messager-body");
if(win.length<=0)
$.messager.show(options);
win = $("body > div .messager-body");
win.window("window").css( {
left : site.left,
top : site.top,
right : site.right,
zIndex : $.fn.window.defaults.zIndex++,
bottom : site.bottom
});
}
});
<a href="#" class="easyui-linkbutton" onclick="showBySite(event)">help</a>
function showBySite(event){
var element = document.elementFromPoint(event.x,event.y);//獲取點擊對象
$.messager.showBySite({
title:'My Title',
msg:'Message.',
showType:'show'
},{
top : $(element).position().top+$(element).height(),//將$.messager.show的top設置為點擊對象之下
left : $(element).position().left,//將$.messager.show的left設置為與點擊對象對齊
bottom : ""
});
}