Handling event outside the iframe for the element within iframe
My page structure is like
I have a html
page which consist of a jQuery
Dialog.
Within the jQuery
Dialog a screen opens within iFrame
.
Now the problem I am facing is - I want to close jQuery
Dialog by clicking a button within iFrame
. (For e.g. If my iFrame source is Google.com, then on click of search button my dialog box should close)
So, Can I write cl开发者_如何学Goose call handling click event of search button in $(document).ready(function()
of my html page?
Note :- iframe source is not accessible.
If no, then what are the other possible option to do it?
Thanks in Advance.
If the iFrame
source is on a different domain than you cannot do this.
Options
Use the Dialog's built in close functionality
If the position of your item that you want to trigger the close is fixed, you can overlay a div covering. Fire the close event on the clicking of the div. http://jsfiddle.net/YvbPB/
See jQuery/JavaScript: accessing contents of an iframe my friend.
精彩评论