Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Trap JS events within an Object Tag

Posted on 2003-11-04
8
Medium Priority
?
305 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 600 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

604 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