How to add a click event to <p>
elements in iframe (using jQuery)
<iframe frameborder="0" id="oframe" src="iframe.html" width="100%" name="oframe">
How to add a click event to <p>
elements in iframe (using jQuery)
<iframe frameborder="0" id="oframe" src="iframe.html" width="100%" name="oframe">
By giving a reference to the IFrame document as the second parameter to jQuery, which is the context:
To access any element from within an iframe, a simple JavaScript approach is as follows:
Now you can select any element using this html element
Now, you can bind any event you want to this element. Hope this helps. Sorry for incorrect English.
Your best best bet is to invoke the iframe AS LONG AS it's part of your domain.
iframe.html
And then use
To invoke that function.
another way is to access the iframe via
window.frames
.and the javascript
That should work fine.
There's a special jQuery function that does that:
.contents()
. See the example for how it's works.