我在aspx页面head标签之间加上如下代码:
<SCRIPT language="javascript">
function winOpen()
{
var coolw=screen.width/3;
var coolh=screen.height/3;
mainwin=window.open ("../agenda.aspx","mainwork","width="+coolw+",height="+coolh+",fullscreen=0,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0");
if (mainwin)
{
mainwin.resizeTo(coolw,coolh);
mainwin.moveTo(0,0);
}
}
</SCRIPT>
再后面有一个linkbutton,在linkbutton标签中我这样写:<.. onClick=winOpen() ..>
提示错误,说winOpen()没有定义,我不知道是怎么回事,明明在上面不是已经定义了吗,请大家来帮帮我,谢谢!!!!!!!!
<SCRIPT language="javascript">
function winOpen()
{
var coolw=screen.width/3;
var coolh=screen.height/3;
mainwin=window.open ("../agenda.aspx","mainwork","width="+coolw+",height="+coolh+",fullscreen=0,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0");
if (mainwin)
{
mainwin.resizeTo(coolw,coolh);
mainwin.moveTo(0,0);
}
}
</SCRIPT>
再后面有一个linkbutton,在linkbutton标签中我这样写:<.. onClick=winOpen() ..>
提示错误,说winOpen()没有定义,我不知道是怎么回事,明明在上面不是已经定义了吗,请大家来帮帮我,谢谢!!!!!!!!
linkbutton..Attributes.Add("onclick","javascript:winOpen()");
还有如果你想关主窗口也是可以的,用
window.opener=null;
window.close();
就好
<asp:LinkButton href="winOpen();"但不推荐这么写
看看下面的例子就了解了<html>
<head>
<title>test</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:LinkButton id="LinkButton1" OnClick="LinkButton1_Click" style="Z-INDEX: 101; LEFT: 138px; POSITION: absolute; TOP: 118px" runat="server" Width="108px" Height="26px">LinkButton</asp:LinkButton>
</form>
<!--服务器端事件-->
<script language="vb" runat="server">
private sub LinkButton1_Click(o as object,e as eventArgs)
response.write("this is server-side event")
end sub
</script>
<!--客户端事件-->
<script language="javascript">
LinkButton1.attachEvent("onclick",LinkButton1_onclick);
function LinkButton1_onclick()
{
alert("this is client-side event");
}
</script>
</body>
</html>