Inserting <script> into iframe with jQuery
问题 I'm attempting to insert a snippet into an iframe through jQuery with the following: var snippet = "<script>document.writeln('test')</script>"; jQuery('<iframe />').appendTo('body').append(snippet); instead of writing "test" in the iframe, it overwrites the parent window. How can I make it so that the parent window gets the iframe with "test" inserted in it? 回答1: You should set the source of new windows and iframes to 'about:blank' if you want control over them. Then reference it by the