Capture mouse events inside an iframe 
August 17th, 2006, 10:55 AM
| | | Capture mouse events inside an iframe
Hello All,
I have an iframe in my main html and within iframe, I'm loading another
HTML webpage. In my main html page, I've captured the mouse click
event, by setting the "onclick" for <bodyof main page.
The code is like this:
<body onclick="handleClickEvent(event)">
....
<iframe src="embedded.html">
</iframe>
....
</body>
My problem is that the event handler is not getting called when I do
mouse clicks inside "iframe".
Is there any way to capture the mouse click event inside iframe?
Thank you,
Venkatesh | 
August 17th, 2006, 11:45 AM
| | | Re: Capture mouse events inside an iframe
Venkatesh wrote: Quote:
I have an iframe in my main html and within iframe, I'm loading another
HTML webpage. In my main html page, I've captured the mouse click
event, by setting the "onclick" for <bodyof main page.
>
The code is like this:
>
<body onclick="handleClickEvent(event)">
<iframe src="embedded.html">
</iframe>
</body>
>
My problem is that the event handler is not getting called when I do
mouse clicks inside "iframe".
Is there any way to capture the mouse click event inside iframe?
| Sure, just do
<body onclick="parent.handleClickEvent(event)">
inside embedded.html.
--
Bart | 
August 17th, 2006, 03:55 PM
| | | Re: Capture mouse events inside an iframe
Thanks Bart for your suggestion. I can try this.
But I have one more question: Is it possible for us to achieve the same
without modifying the html source of embedded html file ??? Because,
the embedded webpage in my case is not written by me, it is coming from
some external URL and modifying the html source of that URL is little
expensive job for me.
Thank you,
Venkatesh
Bart Van der Donck wrote: Quote:
Venkatesh wrote:
> Quote:
I have an iframe in my main html and within iframe, I'm loading another
HTML webpage. In my main html page, I've captured the mouse click
event, by setting the "onclick" for <bodyof main page.
The code is like this:
<body onclick="handleClickEvent(event)">
<iframe src="embedded.html">
</iframe>
</body>
My problem is that the event handler is not getting called when I do
mouse clicks inside "iframe".
Is there any way to capture the mouse click event inside iframe?
| >
Sure, just do
>
<body onclick="parent.handleClickEvent(event)">
>
inside embedded.html.
>
--
Bart
| | 
August 18th, 2006, 04:35 AM
| | | Re: Capture mouse events inside an iframe
Hi,
Just wanted to add. I tried parent.handleClickEvent(event)
I'm getting a javascript error for this. On FireFox, the error message
is:
uncaught exception: Permission denied to get property
window.handleClickEvent
Does anybody have an idea of why is this exception coming? Is this some
security related error? and should we set any browser properties to
overcome this problem?
Thank you,
Venkatesh
Venkatesh wrote: Quote:
Thanks Bart for your suggestion. I can try this.
>
But I have one more question: Is it possible for us to achieve the same
without modifying the html source of embedded html file ??? Because,
the embedded webpage in my case is not written by me, it is coming from
some external URL and modifying the html source of that URL is little
expensive job for me.
>
Thank you,
Venkatesh
>
Bart Van der Donck wrote: Quote:
Venkatesh wrote: Quote:
I have an iframe in my main html and within iframe, I'm loading another
HTML webpage. In my main html page, I've captured the mouse click
event, by setting the "onclick" for <bodyof main page.
>
The code is like this:
>
<body onclick="handleClickEvent(event)">
<iframe src="embedded.html">
</iframe>
</body>
>
My problem is that the event handler is not getting called when I do
mouse clicks inside "iframe".
Is there any way to capture the mouse click event inside iframe?
| Sure, just do
<body onclick="parent.handleClickEvent(event)">
inside embedded.html.
--
Bart
| | | 
August 18th, 2006, 06:25 AM
| | | Re: Capture mouse events inside an iframe
Venkatesh wrote: Please don't top-post here. Reply below a trimmed quote. Quote:
Just wanted to add. I tried parent.handleClickEvent(event)
>
I'm getting a javascript error for this. On FireFox, the error message
is:
>
uncaught exception: Permission denied to get property
window.handleClickEvent
>
Does anybody have an idea of why is this exception coming? Is this some
security related error? and should we set any browser properties to
overcome this problem?
| Google "javascript cross domain security"
[...] Quote: Quote:
But I have one more question: Is it possible for us to achieve the same
without modifying the html source of embedded html file ??? Because,
the embedded webpage in my case is not written by me, it is coming from
some external URL and modifying the html source of that URL is little
expensive job for me.
| | You either change the source of the iFrame or you convince the browser
user to relax their security permissions. Most users will probably
refuse to do so, since allowing a page to access and modify another
page hosted in an iFrame is a rather large security risk - hence the
default setting to prevent cross-domain scripting.
<URL: http://ajaxian.com/archives/cross-do...jax-insecurity >
<URL: http://jszen.blogspot.com/2005/03/cr...rity-woes.html >
--
Rob | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,989 network members.
|