Question : is there any way to fire a onclick with javascript?

Hello guys

After my page load, I want to simulate a click on a cell, is it possible?

Take a look at this  simple code that I have done:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script language="javascript">
  function showmsg(str){
		alert(str)
		}
</script>
</head>

<body>
<table width="500" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td id="cel1" width="244" onclick="showmsg('teste')">clique aqui</td>
    <td width="256" align="left" ><span style="margin-left:2px"> aaaaaaa </span></td>
  </tr>
</table>
<script> 
  document.getElementById("cel1").click()
</script>
</body>
</html>

Answer : is there any way to fire a onclick with javascript?

see example:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="text/javascript">
function showmsg(str) {
	alert(str);
}
function performClick(node) {
	var evt = document.createEvent("MouseEvents");
	evt.initEvent("click", true, false);
	node.dispatchEvent(evt);
}
window.onload = function() {
	performClick(document.getElementById("cel1"));
}
</script>
</head>

<body>
<table width="500" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td id="cel1" width="244" onclick="showmsg('test')">clique aqui</td>
    <td width="256" align="left" ><span style="margin-left:2px"> aaaaaaa </span></td>
  </tr>
</table>
<script> 
  document.getElementById("cel1").click()
</script>
</body>
</html>
Random Solutions  
 
programming4us programming4us