By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,382 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,382 IT Pros & Developers. It's quick & easy.

can you "inline" event handlers for objects in 1 script like in VBScript?

P: n/a
This seems awkward, isn't there a better way to place event handlers
in the rest of the code with the logic for everything else like you
can with VBScript?

<script language="javascript"
if (myvar == true " {
do something
}
lots more code here...

</script>

<script for="myActiveX" event="Onclick()" language="javascript">
code for this event
</script>

<script for="myTreeView" event="OnConnect()" language="javascript">
code for this event
</script>
....

In other words, can I put it all between one <script></script> tag?

Thanks,

Fred
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
fd*****@aol.com (Fred) writes:
This seems awkward, isn't there a better way to place event handlers
in the rest of the code with the logic for everything else like you
can with VBScript?
I don't know what you can with VBScritp. Can you explain what you want
to achieve?
<script for="myActiveX" event="Onclick()" language="javascript">
This construction only works in IE.
In other words, can I put it all between one <script></script> tag?


Sure

<script type="text/javascript">
function myHandler1(event) {...}
function myHandler2(event) {...}
...
document.getElementById("myActiveX").onclick = myHandler1;
document.getElementById("myActiveX").onconnect = myHandler2;
/* don't know the onconnect evemt, must be IE specific too */
</script>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.