Solved

Trap JS events within an Object Tag

Posted on 2003-11-04
8
301 Views
Last Modified: 2012-06-27
Hello, I have a html like this

<object id="UploadControl" width="100%" height="100%" classid="clsid:1E2941E3-8E63-11D4-9D5A-00902742D6E0" codebase="<<some .cab file>> Version=5,0,3,0">
<param name="SampeName" value="1">
<<... other params come here>>
</object>

This tag is primarily used in a mail application to display attachments in that mail. When a user double-clicks on one of the attachments, I want to be able to trap that event and display a custom alert. Currently, the attachment opens up using it's respective application. I am not able to prevent it from going to the application and instead display a custom message. I have tried giving 'onLoad' events on the object tag, a div tag that encloses it, on the body tag. Also tried this

<script language=javascript for="UploadControl" event="onfocus">
alert('handler comes here');
</script>

but all in vain. Could someone please help me with idea(s) to trap the javascript events on an Object tag with code base for an ActiveX control?
0
Comment
Question by:shyam619
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
8 Comments
 
LVL 10

Expert Comment

by:Nushi
ID: 9684577
hi there.

i havent tried it with object but you can do the following:

<div onclick="alert('....')">
  <object .... >
</div>

now when the user clicks on something inside the object it should trap the mouse event.
there can be some exceptions:

whne you click on a button the button i dont know the sequesnce
it will execute the onclick.


another solution (not recommanded) is to capture mouse event
in the document and then see if the source is the object.

document.onclick = new function(){
                                                         if ( get Source based on browser == object element)  
                                                              alert('a')
                                                      }


Nushi.



0
 
LVL 10

Expert Comment

by:Nushi
ID: 9684584
the problem is that object is a seperate application so my guess that
the solution i gave you above will not work, but you still can give it a shot.
0
 

Author Comment

by:shyam619
ID: 9684603
Thanks Nushi. I have already tried the div tag approach. It is not working. Anything on the div, it displays the alert alright. But inside the object tag even though it is part of the div too, it fails to catch the event.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:shyam619
ID: 9684616
Also, I have a script like this to find out the source of the event. This does not work either.

<SCRIPT LANGUAGE="JavaScript">

function click()
{
alert('entered function for click');
  if(event.button == 0)
  {
    alert(event.button);
    alert(event.srcElement.tagName);
    alert(event.srcElement.name);
  }
  return false;
}

document.getElementById('div name here').ondblclick=click;
</SCRIPT>
0
 
LVL 10

Accepted Solution

by:
Nushi earned 200 total points
ID: 9684995
Thats what i thought.
Object is an ActiveX which is independed.

what im tring to say is that Object doesnt have option to capture event unless
its part of the control.
whenever object is located inside the HTML its "capture" its own space
in which user/code can't get to it.

as far as i know there isnt any solution.

Nushi.
0
 
LVL 10

Expert Comment

by:Nushi
ID: 9686101
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10352735
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: Nushi {http:#9686101}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question