Welcome to Dream.In.Code
Become an Expert!

Join 149,507 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,342 people online right now. Registration is fast and FREE... Join Now!




Onclick doesn't respond in object element

 
Reply to this topicStart new topic

Onclick doesn't respond in object element, onmouseover runs fine but both of them should

OutOfRange
26 Jul, 2007 - 10:30 AM
Post #1

New D.I.C Head
*

Joined: 22 Jul, 2007
Posts: 5


My Contributions

I've the following code on my source page.

CODE

<object data="anormalhtmlpage.htm" type="text/html"
onmouseover="alert('mouse over');return false;"
onclick="alert('mouse clicked'); return false;">


Onmouseover runs as it should BUT onclick doesn't respond
at all.

Could someone tell why and what is wrong with the excerpt?

Thanks in advance
User is offlineProfile CardPM
+Quote Post

serializer
RE: Onclick Doesn't Respond In Object Element
27 Jul, 2007 - 09:29 AM
Post #2

D.I.C Head
**

Joined: 25 Jun, 2007
Posts: 108


My Contributions
I just did a quick test, and it seems the browser delegates mouse events to the embedded page, so only onclick events in anormalhtmlpage.htm will fire.

You could perhaps use Javascript to manually attach events to the embedded page through the DOM.

Or, you could position a transparent <div> over the top of the object, and check for onclick events there. Only that will break any links and so forth in your embedded page, but it looks like you might want that feature anyway.

--serializer
User is offlineProfile CardPM
+Quote Post

OutOfRange
RE: Onclick Doesn't Respond In Object Element
28 Jul, 2007 - 01:44 AM
Post #3

New D.I.C Head
*

Joined: 22 Jul, 2007
Posts: 5


My Contributions

This seems to be a tricky bit.

Some browsers show both onmouseover and onclick (Konqueror). Some only onmouseover (Firefox, Opera) and i don't know yet what IE shows.

Unfortunately, it is not possible to manipulate the pages that will be shown in the object-element. They are maintained by others.

Neither can i apply the layer trick as the user has to be able to click on links on the loaded page. Currently, he can but the view in the main page jumps to the top, which is the original problem.

As my previous experiments show, the loaded page can be scrolled with javascript without problems. It is the links that causes the problems. It may have something to do with the hash-stuff...

I tried to use the onclick event and cancel the links in this way but as it is not captured by the (majority of) browsers it doesn't seem as a promising thread.




QUOTE(OutOfRange @ 26 Jul, 2007 - 11:30 AM) *

I've the following code on my source page.

CODE

<object data="anormalhtmlpage.htm" type="text/html"
onmouseover="alert('mouse over');return false;"
onclick="alert('mouse clicked'); return false;">


Onmouseover runs as it should BUT onclick doesn't respond
at all.

Could someone tell why and what is wrong with the excerpt?

Thanks in advance


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 07:21PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month