Appear div to close only after clicking iframe

Asked

Viewed 582 times

3

It is possible to have a div with a iframe and only after the user has clicked on one of the links within the iframe, would appear a div to say fechar and when the user clicked there, closed the div fechar and the div which contained the iframe?

2 answers

3


  • The question is not this friend, what I really want is, ex: I have a youtube video and on top I have the div to cover the video and only when the person clicks on the advertising is opening another div to say to close, got it? : ss

  • Next, I updated the example, maybe it is close to what you want.

  • That’s right, only when clicking a link inside the iframe appeared a div that said: Close, and when clicking there, close.. It is possible?

  • Yes, it is possible, for such in the place of calling the . confirm(), you would have to make this div visible, inside this div you would have a button or input[Submit] that would close both div and iframe.

  • I made one last change, when I click on an iframe link and it navigates to this link, the message will appear to close. as I told you before, you only need a small script change to show a div instead of confirm.

  • Can you help me with that in a jsfiddle please? and sorry :ss

  • @thecreator, here’s the change you requested: http://jsfiddle.net/0nh8ms29/1/

  • There are only two problems friend, http://jsfiddle.net/0nh8ms29/4/ 1º the background of the modal "superimpose" the modal and the second is: In the upper left corner of the iframe you have facebook linkk, google+ etc.. If you click on one of these links you will go to an external page, and the button will not close.. what I wanted was that even if it was the target = Blank, that appeared the button close..

  • this is a limitation of CORS (cross-origin Resource sharing), you cannot manipulate the elements from within iframe when they belong to another domain.

  • instead of .loadI can’t put .click?

Show 6 more comments

2

Yes @thecreator is possible. For this you can use jQuery. I think this tutorial can help you. See also this reply which deals with the same issue.

Updating It would be something like this:

document.getElementById( 'frame' ).addEventListener( 'click', function( event ){
    $("#Mensagem").show();
})

Inside the DIV message you will have a link or button that closes the div that contains the frame.

  • No, it’s not the same question. What I want is a box (div) that will contain a google iframe (advertising) and only by clicking on the link of one of these advertising, another appears DIV to say to close the box (div).

  • I got it, I updated the answer. See if you can do it this way. To solve it, you need to "monitor" the click on the advertising frame. When the user clicksVoce opens another div telling to close the box.

  • You can make a Jsfiddle so you can help me a little more?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.