code_junkie

Trouble Using JQuery UI.Resizable() and UI.Draggable() with an iFrame

Nov 14th, 2011
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <div id="container" style="border: solid 1px Black; padding: 10px 10px 10px 10px; height: 520px; width: 420px;">
  2. <iframe id="if" src="http://google.com" style="width: 400px; height: 500px;"></iframe>
  3. </div>
  4.  
  5. <script type="text/javascript" src="jquery-1.2.6.js"></script>
  6. <script type="text/javascript" src="jquery.ui.all.js"></script>
  7. <script type="text/javascript">
  8.  
  9. $(document).ready(function()
  10. {
  11. $("#container").draggable();
  12. $("#container").resizable(
  13. {
  14. alsoResize: "#if"
  15. }
  16. ).parent().draggable();
  17. }
  18. );
  19.  
  20. $elements.resizable({ //mark it as resizable
  21. containment: "#docCanvas",
  22. start: function(event, ui) {
  23. //add a mask over the Iframe to prevent IE from stealing mouse events
  24. $j("#docCanvas").append("<div id="mask" style="background-image:url(images/spacer.gif); position: absolute; z-index: 2; left: 0pt; top: 0pt; right: 0pt; bottom: 0pt;"></div>");
  25. },
  26. stop: function(event, ui) {
  27. //remove mask when dragging ends
  28. $j("#mask").remove();
  29. }
  30. });
  31.  
  32. <div id="docCanvas" style="position: relative;">
  33. <iframe src="something.html"></iframe>
  34. </div>
  35.  
  36. // this will make <div id="box"> resizable() and draggable()
  37. $('#box').resizable().parent().draggable();
  38.  
  39. // same but slightly safer since it checks parent's class
  40. $('#box').resizable().parent('.ui-wrapper').draggable();
  41.  
  42. function uncoverIframes() {
  43. $(".cover").remove();
  44. }
Add Comment
Please, Sign In to add comment