首页 > 编程 > .NET > 正文

[ASP.NET]一个实用的弹出窗口函数

2024-07-10 12:56:41
字体:
来源:转载
供稿:网友
public static void openpopup(system.web.ui.webcontrols.webcontrol opener,string pagepath,string windowname,int top,int left,int width,int height)
{
string clientscript;
string windowattribs;
windowattribs = "left=" + left.tostring() + "px," +
"top=" + top.tostring() + "px," +
"width=" + width.tostring() + "px," +
"height=" + height.tostring() + "px," +
"left='+((screen.width -" + width.tostring()+ ") / 2)+',";
clientscript = "window.open('"+pagepath+ "','"+
windowname + "','"+ windowattribs + "');return false;";
opener.attributes.add("onclick", clientscript);
}

private void page_load(object sender, system.eventargs e)
{
// 在此处放置用户代码以初始化页面
if(!ispostback)
{
openpopup(button1,"http://www.google.com";);
openpopup(button2,"http://www.google.com";,"",0,0,300,300);
}
}


国内最大的酷站演示中心!
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表