当前位置: 代码迷 >> JavaScript >> 为啥不响应onclick
  详细解决方案

为啥不响应onclick

热度:174   发布时间:2013-04-09 16:45:09.0
为什么不响应onclick
<!DO
CTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<script>
  document.getElementById("ttt").onclick = y1; 
function y1()
{
  window.open("test.jpg","test","height=400,width=400,menubar=no,location=yes,Resizable=no");
  return false;
  }
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<a href="#" id="ttt">link1</a>
</body>
</html>

------解决方案--------------------
必须写在这些元素之后 
============
在这些元素加载之后执行
  相关解决方案