473,382 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Handling ActiveX events in JavaScript (Internet Explorer)

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?

Oct 24 '05 #1
3 19002
Sorry

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

This code works as I wanted.

Oct 24 '05 #2
kl**********@gmail.com 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
Oct 24 '05 #3
RobG said the following on 10/24/2005 5:05 PM:
kl**********@gmail.com 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
Oct 24 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: wang xiaoyu | last post by:
Hello: i want use activex in wxpython program,but when i use MakeActiveXClass an exception occurs. this is my source code dealing the DICOM ocx.I must note that in this program "hwtxcontrol" is...
0
by: Jeff M | last post by:
For my application an activeX refers to "program displayed within Internet Explorer" After looking over the docs for VB.NET it looks impossible. ---START--- USERCONTROL CHANGES IN VISUAL...
2
by: Fie Fie Niles | last post by:
This one XP machine (with IE 6) is having a problem viewing any ActiveX controls (created on VB6) on the Internet Explorer browser. I put the same ActiveX control in a VB program, and when I run...
4
by: joebob | last post by:
The following script if run in Internet Explorer should display a thumbview of a webpage that you point it to. To test it, replace test.htm with a valid html file. The problem I'm having is that...
12
by: A.M. | last post by:
Hi at all, how can I do to insert into a HTML page a file .txt stored in the same directory of the server where is the html file that must display the text file.txt? Thank you very much P.Pietro
3
by: EJ1003 | last post by:
Hello I would like to create Activex Control uisng C# and use it in ASP.Net webform. User Control is not solving my requirement so I am going for Activex Control. Please guide me on this, how...
8
by: Klaus Jensen | last post by:
Hi! I would like to build a small application, that should be embedded in a webpage. I want to develop it using VB.Net of course, and have the usual opportunities of a windows app... A common...
1
by: Apu Nahasapeemapetilon | last post by:
Hello and thank you in advance for your help. Can anyone think of a reason why this code would work properly on one PC, but not another? I've got a System.Windows.Forms.UserControl that...
1
by: Adam Clauss | last post by:
We have created an ActiveX control (a series of them actually) which can be loaded into Internet Explorer and accessed via Javascript using the techniques described here:...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.