javascript onclick with iframe |
![]() ![]() |
javascript onclick with iframe |
![]()
Post
#1
|
|
![]() /人◕‿‿◕人\ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Official Member Posts: 8,283 Joined: Dec 2007 Member No: 602,927 ![]() |
I need to make it so a javascript onclick alert works whenever I click in an iframe.
CODE <iframe src="http://example.com" name="frame1" scrolling="auto" frameborder="no" align="center" height = "100%" width = "100%" onClick="alert('test')";> </iframe> that's just not working for some reason. It's probably something really simple keeping it from working too. |
|
|
![]()
Post
#2
|
|
Senior Member ![]() ![]() ![]() ![]() ![]() ![]() Group: Member Posts: 1,237 Joined: May 2008 Member No: 648,123 ![]() |
The really simple thing is that the onclick attribute doesn't exist for iframes. You get to make use of onload instead, something like this:
CODE <iframe onload="this.contentWindow.document.onclick=function(){alert('test')}"></iframe> .contentWindow is self-explanatory: the contents of the current iframe. |
|
|
![]() ![]() |