• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

Trap JS events within an Object Tag

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
shyam619
Asked:
shyam619
  • 4
  • 2
1 Solution
 
NushiCommented:
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
 
NushiCommented:
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
 
shyam619Author Commented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
shyam619Author Commented:
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
 
NushiCommented:
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
 
jaysolomonCommented:
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now