1
$(document).ready(function(){
   $("#container").click(function(){
      $("#myiframe").attr('src', 'example.com');
   });
});

This doesn't work? The container is actually is a lightbox. The reason I am not defining the src attribute by default is because iframe loads even when lightbox isn't shown yet.

1 Answer 1

4

try:

$("#myiframe").get(0).contentWindow.location.href = 'example.com';

I think setting src isn't going to do anything after page load.

Sign up to request clarification or add additional context in comments.

2 Comments

Ok it does work.. I don't know why it didn't work on the first day I tested it... But how do I unload it?
simply do $("#myiframe").get(0).contentWindow.location.href = 'about:blank';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.