Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Handling ActiveX events in JavaScript (Internet Explorer)

Reply
Thread Tools

Handling ActiveX events in JavaScript (Internet Explorer)

 
 
klimontovich@gmail.com
Guest
Posts: n/a
 
      10-24-2005
Hello!

I'm trying to handle events raising by Microsoft ActiveX Spreadsheet
control.
I use following code to include this control into page:

<object classid="clsid:0002E551-0000-0000-C000-000000000046"
id="Spreadsheet1"">

</object>

Than i'm trying to handle onclick event by following code:

Spreadsheet1.onclick = function() {
alert(1);
}

This code has no effect -- no alert message, but no error message. But
the following code:

Spreadsheet1.click = function() {
alert(1);
}

raises error "object doesn't support this action". This means, that
onclick event is khown by javascript. But by using VBScript I can hanle
onclick event,
this code works right:

Sub Spreadsheet1_click()
alert Spreadsheet1.cells(5,4).value
End Sub

Does anybode have experience in catching activeX events by JS?

 
Reply With Quote
 
 
 
 
klimontovich@gmail.com
Guest
Posts: n/a
 
      10-24-2005
Sorry

<SCRIPT FOR="Spreadsheet1" EVENT="click()" LANGUAGE="Jscript">
alert(1);
</SCRIPT>

This code works as I wanted.

 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      10-24-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Sorry
>
> <SCRIPT FOR="Spreadsheet1" EVENT="click()" LANGUAGE="Jscript">
> alert(1);
> </SCRIPT>
>
> This code works as I wanted.


Using a 'for' attribute on a script element to add it to an element is
an 'IE-ism' that will only work in IE.

Likely your page only works in IE anyway, but for the record some
cross-browser ways of adding the onclick to the object element are to
either add it inline, directly in the <object> HTML source tag:

<object classid="clsid:0002E551-0000-0000-C000-000000000046"
id="Spreadsheet1"
onclick="alert(1)";
>...</object>


or add it dynamically after the object has been created:

<object id="Spreadsheet1"...>...</object>

<script type="text/javascript">
var el;
if (document.getElementById){
el = document.getElementById('Spreadsheet1');
} else if (document.all){
el = document.all['Spreadsheet1'];
}
el.onclick = function(){alert(1);};
</script>

If you don't need to support old IE, document.all bit can be removed.
Check out the group FAQ for various options:

<URL:http://www.jibbering.com/faq/#FAQ4_15>




--
Rob
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      10-24-2005
RobG said the following on 10/24/2005 5:05 PM:
> (E-Mail Removed) wrote:
>
>> Sorry
>>
>> <SCRIPT FOR="Spreadsheet1" EVENT="click()" LANGUAGE="Jscript">
>> alert(1);
>> </SCRIPT>
>>
>> This code works as I wanted.

>
>
> Using a 'for' attribute on a script element to add it to an element is
> an 'IE-ism' that will only work in IE.


I doubt that an ActiveX Control controlling a Spreadsheet control will
working anything *but* IE so using IE-only code is not a problem.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
 
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
ActiveX control in python vs ActiveX control in vb 6 (piece of code) vml Python 0 08-22-2007 09:57 AM
Events Events Events Please Help Chris ASP .Net Web Controls 0 08-30-2005 08:21 PM
ActiveX apologetic Larry Seltzer... "Sun paid for malicious ActiveX code, and Firefox is bad, bad bad baad. please use ActiveX, it's secure and nice!" (ok, the last part is irony on my part) fernando.cassia@gmail.com Java 0 04-16-2005 10:05 PM
handling activex events Felipe Garcia ASP .Net 1 07-21-2004 04:02 PM
Smartnavigation disables ActiveX Events (OWC) Kevin Ortman ASP .Net 0 12-05-2003 04:28 AM



Advertisments