<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body>&gt; Hi&nbsp;gang:<BR>&nbsp;<BR>&gt; 1.&nbsp;Why&nbsp;do&nbsp;the&nbsp;alerts&nbsp;show&nbsp;at&nbsp;start-up?<BR>
That's because with:&nbsp;<FONT><FONT>a.<FONT>onclick</FONT></FONT></FONT>&nbsp;=&nbsp;test1(1)<BR>
You are&nbsp;assigning the complete body function to the <FONT>a.onclick (!treated as system "undefined" something)</FONT><BR>
it's the same as if you've writen:<BR>
test1(c)&nbsp;{<BR>&nbsp;var d = c + 1;<BR>&nbsp;alert(d);<BR>
equals anonymous <FONT>load-time function only that in this case; nowhere to assign c=1.</FONT><BR>
&nbsp;<BR>
&gt; 2.&nbsp;Why&nbsp;does&nbsp;the&nbsp;onclick&nbsp;not&nbsp;work&nbsp;(i.e.,&nbsp;no&nbsp;alerts)?<BR><BR>
Because it's not associated with the HTMLobject.event&nbsp;<BR> <BR>&gt; What&nbsp;I&nbsp;simply&nbsp;want&nbsp;to&nbsp;do&nbsp;is&nbsp;to&nbsp;call&nbsp;a&nbsp;function&nbsp;(while&nbsp;passing&nbsp;a&nbsp;<BR>&gt; variable)&nbsp;by&nbsp;clicking&nbsp;a&nbsp;div.<BR>At my knowledge, it &nbsp;can be done only through inline event function calls, that is:<BR>
&lt;div&nbsp;id="test1" onclick="test(1,2,3)"&gt;&nbsp;This&nbsp;is&nbsp;test&nbsp;1&nbsp;&lt;/div&gt;<BR>while the script could go like:<BR>
function test1(one,two,three)&nbsp;{<BR>&nbsp;var d =&nbsp;two + 1;<BR>&nbsp;alert(d);<BR>&nbsp;} <BR>
***some inline comments******<BR>
&gt; html&nbsp;--<BR>&gt; <BR>&gt; &lt;div&nbsp;id="test1"&gt;<BR>&gt; This&nbsp;is&nbsp;test&nbsp;1<BR>&gt; &lt;/div&gt;<BR>&gt; <BR>&gt; &lt;div&nbsp;id="test2"&gt;<BR>&gt; This&nbsp;is&nbsp;test&nbsp;2<BR>&gt; &lt;/div&gt;<BR>&gt; <BR>&gt; <BR>&gt; js&nbsp;---<BR>&gt; <BR>&gt; &lt;script&nbsp;type="text/javascript"&gt;<BR>&gt; <BR>&gt; var&nbsp;a&nbsp;=&nbsp; document.getElementById("test1");<BR>&gt; var&nbsp;b&nbsp;=&nbsp; document.getElementById("test2");<BR>&gt; <BR>&gt; function&nbsp;test1(c)//In Netscape Browsers this will assign the onclick event to to the c variable;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;<FONT><FONT>ie will&nbsp;treat it as undeclared&nbsp;empty var&nbsp;</FONT></FONT><BR>
&gt; {<BR>&gt; var&nbsp;d&nbsp;=&nbsp;c&nbsp;+&nbsp;1;//You are adding 1(number) to click event object; in ie you are adding NaN +1<BR>&gt; alert(d);&nbsp;&nbsp;&nbsp; //will result click event 1 ; in ie NaN<BR>&gt; }<BR>&gt; <BR>&gt; function&nbsp;test2()<BR>&gt; {<BR>&gt; var&nbsp;d&nbsp;=&nbsp;1; //correctly &nbsp;assigned, value of d var is 1<BR>&gt; alert(d);// will alert 1<BR>&gt; }<BR>&gt; <BR>
&gt; <FONT>a.<FONT>onclick</FONT></FONT>&nbsp;=&nbsp;test1(1);//loadtime c: will alert (2) in&nbsp;1 will be assigned to <FONT>c</FONT>; In ie&nbsp;same but immediately followed by error<BR>&gt; <FONT><FONT>b.onclick</FONT></FONT>&nbsp;=&nbsp;test2();//correctly will alert (1); but ie has stopped load time exec after that error, no result will&nbsp;alert.<BR>&gt; <BR>&gt; &lt;/script&gt;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
Or something <BR>&gt; --&nbsp;<BR>&gt; -------<BR>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Troy&nbsp;III<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;progressive&nbsp;art&nbsp;enterprise<BR>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<BR><BR><br /><hr />Be one of the first to try Windows Live Mail. <a href='http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d' target='_new'>Windows Live Mail.</a></body>
</html>