Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > can you "inline" event handlers for objects in 1 script like in VBScript?

Reply
Thread Tools

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

 
 
Fred
Guest
Posts: n/a
 
      07-18-2003
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
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      07-18-2003
(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 -
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
don't like, so don't waste your time thinking and buy them. You know,if you don't like one thing, it means nothing for you.</p> fashion t shirts seller Cisco 0 06-13-2011 02:01 AM
if you have free time ,you can chose the pro of you like sara_love67 Computer Support 7 09-25-2007 08:29 PM
if you have free time ,you can chose the pro of you like sara_love67 Digital Photography 0 09-24-2007 08:19 PM
Security Exception When You Use Event Handlers in Internet Explore Gert Unterhofer ASP .Net Security 0 07-17-2006 05:30 PM
Axis - Can handlers get access to provider objects? Paco Java 0 02-21-2006 09:56 PM



Advertisments
 



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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57