Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script type="text/javascript" src="jquery-1.10.2.min.js"></script>
  4. <script>
  5. $(function () {
  6. var result_html = "<html><body>foo</body></html>";
  7. var type_html = 'text/html';
  8. var fBlob_html = new Blob([result_html], {type : type_html});
  9. var fURL_html = window.URL.createObjectURL(fBlob_html);
  10. var oBlob_html = new Blob([result_html], {type : type_html});
  11. var oURL_html = window.URL.createObjectURL(oBlob_html);
  12. // this works
  13. $("#fResult_html").attr('src', fURL_html);
  14. // this does not work
  15. $("#oResult_html").attr('type', type_html);
  16. $("#oResult_html").attr('data', oURL_html);
  17.  
  18. var result_json = '{"foo":bar}';
  19. var type_json = 'application/json';
  20. var fBlob_json = new Blob([result_json], {type : type_json});
  21. var fURL_json = window.URL.createObjectURL(fBlob_json);
  22. var oBlob_json = new Blob([result_json], {type : type_json});
  23. var oURL_json = window.URL.createObjectURL(oBlob_json);
  24. // this works, but complains that the type is not a Document
  25. $("#fResult_json").attr('src', fURL_json);
  26. // this does not work
  27. $("#oResult_json").attr('type', type_json);
  28. $("#oResult_json").attr('data', oURL_json);
  29. });
  30. </script>
  31. </head>
  32. <body>
  33. <iframe id="fResult_html" width="200px" height="200px">
  34. </iframe>
  35. <object id="oResult_html" width="200px" height="200px">
  36. </object>
  37. <iframe id="fResult_json" width="200px" height="200px">
  38. </iframe>
  39. <object id="oResult_json" width="200px" height="200px">
  40. </object>
  41. </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement