Last active
August 29, 2015 14:13
-
-
Save tonyfast/0b4aab02bd3c5427a702 to your computer and use it in GitHub Desktop.
Dynamically create an iframe using a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <head> | |
| <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> | |
| <script> | |
| var head = 'data:text/html;charset=utf-8,', // html headers | |
| src = '<body><h1>This is a the page source</h1><p>Here is the text body.</p></body>'; //html content | |
| $(document).ready( function(){ | |
| $('<iframe/>').appendTo( 'body' ) | |
| .attr( 'src' , head + src ); | |
| return null | |
| }); | |
| </script> | |
| </head> | |
| <body></body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment