View Full Version : iFrame javascript communication
Shard
September 6th, 2007, 08:15 AM
Hi all, I have an iframe (named 'base') that I want to capture the right mouse click event in and have it handled by a function in the containing document (parent) ...
frames['base'].document.body.onContextMenu="return parent.navwheel()";
... but even if i make the function navwheel a simple alert - it never gets called????
Any help or clues greatly appreciated. :-)
Shard
September 6th, 2007, 08:41 AM
Figured it out - with thanks to the good old DOM inspector. The previous code was definately adding the onContextMenu code, but in the wrong place. You need to add it as a root level node of the body....
frames['base'].document.body.setAttribute('onContextMenu',"return parent.navwheel()");
Just thought i'd paste the solution in case it helps someone else one day :-)
thats all folks
September 6th, 2007, 09:39 AM
Thanks for posting the solution!
Shard
September 9th, 2007, 08:53 AM
Thanks for posting the solution!
IE7 has a problem with the way the event has been attached ...
frames['base'].document.body.setAttribute('onContextMenu',"return parent.navwheel()");
.. any ideas anyone for a cross browser implementation of a contextmenu capture??
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.