弹出窗口相关JavaScript
event.x,event.clientX,event.offsetX区别:
x:设置或者是得到鼠标相对于目标事件的父元素的外边界在x坐标上的位置。
clientX:相对于客户区域的x坐标位置,不包括滚动条,就是正文区域。
offsetx:设置或者是得到鼠标相对于目标事件的父元素的内边界在x坐标上的位置。
screenX:相对于用户屏幕。
//功能:使窗口获得焦点
function WindowFocus()
{
//this.focus();
if(event.clientX <= 0 || event.clientY <= 0 || event.clientX >= document.body.clientWidth || event.clientY >= document.body.clientHeight )
{
this.focus();
}
}
引用οnblur="WindowFocus()"模仿模态窗口
//刷新指定页面
function RefreshWindow()
{
//if(event.clientX < 0 && event.clientY < 0)
//{
var strProjectID;
strProjectID = document.all("txtProjectID").value;
//strProjectID = '<%=Session["ProjectID"]%>';
window.opener.location.href = 'PlanTaskListShow.aspx?ProjectID=' + strProjectID;
//}
}
</script>
引用 οnunlοad="RefreshWindow()" 关闭窗口时刷新某页面
//打开新窗口
function WindowOpen(strUrl ,strWidth ,strHeight)
{
var strFeature ;
if(arguments.length == 1)
{
strFeature = "top= 20,left=100,height=400,width=650,toolbar= no,menubar = no,scrollbars =yes,resizable=no,location=no,status=no/");window.close();"
}
else
{
strFeature = "top= 20,left=100,height="+strHeight+",width="+strWidth+",toolbar= no,menubar = no,scrollbars =yes,resizable=no,location=no,status=no/");window.close();"
}
window.open(strUrl,'_blank',strFeature);
}
//在固定位置打开特定窗口(打开帮助文档实例)
function HelpDocumentOpen()
{
var strUrl;
var intDotIndex ; //后缀小数点的位置
var strFeature ;
var strWidth ;
var strHeight;
var strTop ;
var strLeft ;
var intIndex ;
var strAppName ; //安装的目录名称
strAppName = location.pathname.toLowerCase();
intIndex = strAppName.indexOf("/",1);
strAppName = strAppName.substr(0,intIndex+1);
strUrl = window.location.href.toLowerCase(); //页面的联接
strUrl = strUrl.replace(strAppName,strAppName+"help/"); //替换为新的联接文档页面
intDotIndex = strUrl.lastIndexOf(".");
strUrl = strUrl.substr(0,intDotIndex+1);
strUrl = strUrl + "htm" ;
strWidth = 550;
strHeight = 750;
strTop = 20 ;
strLeft = screen.availWidth - strWidth -20;
strFeature = "top= "+strTop+",left="+strLeft+",height="+strHeight+",width="+strWidth+",toolbar= no,menubar = no,scrollbars =yes,resizable=yes,location=no,status=no/");window.close();"
//window.open(strUrl,'_blank',strFeature) ;
window.open(strUrl ,'HelpWindow',strFeature);
//window.showHelp(strUrl,0, strFeature); //可以考虑
}