读书人

JavaScript奇怪有关问题

发布时间: 2012-01-15 22:57:49 作者: rapoo

JavaScript奇怪问题
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> Untitled Page </title>
<script type= "text/javascript ">
function select()
{
window.alert( "text ");
}
</script>
</head>
<body >
<form id= "form1 " runat= "server ">
<input type= "button " id= "button " value= "select a value " onclick= "select() " />  
<input type= "button " id= "button2 " value= "select a value " onclick= "javascript:document.form1.text1.value=showModalDialog( 'Default3.aspx ',3) " /> <br/>
<input type= "text " id= "text1 " />
</form>
</body>

</html>

现在的问题是:
<input type= "button " id= "button " value= "select a value " onclick= "select() " /> 并没有弹出警告框!
<input type= "button " id= "button " value= "select a value " onclick= "javascript:alert( 'text ') " /> 却可以。
什么原因?

[解决办法]
不要用select来命名函数
select是属性
换个名

读书人网 >asp.net

热点推荐