jquery - 使用 jQuery UI 调整 iFrame 大小

标签 jquery iframe user-interface resize

我有这段代码,它工作正常:

    <script>
    $(document).ready(function()
    {
        $("#test").resizable({minHeight: 50, minWidth: 50});
    });
</script>

正文

<div id="test" style="border: .1em solid black;">
</div>

但是,当我将“div”更改为“iframe”时,我无法再调整它的大小。

正文

<iframe id="test" style="border: .1em solid black;">
</iframe>

最佳答案

当一次将鼠标移动超过几个像素时,发现 redsquare 的演示有点不稳定。我应用了一些修改,有助于使调整大小更加顺畅:

<html>
<head>
  <style type="text/css"> 
    #resizable { width: 150px; height: 150px; padding: 0.5em; }
    #resizable h3 { text-align: center; margin: 0; }
    .ui-resizable-helper { border: 75px solid #EFEFEF; margin: -75px; }
  </style> 
  <script type="text/javascript"> 
    $(function() {
      $("#resizable").resizable({
        helper: "ui-resizable-helper"
      });
    });
  </script> 
</head> 
<body> 
  <div class="demo"> 
    <div id="resizable" class="ui-widget-content"> 
      <iframe src="http://pastebin.me/f9ed9b9d36d17a7987e9cb670e01f0e2" class="ui-widget-content" frameborder="no" id="test" width="100%" height="100%" />
    </div> 
  <div>
</body>
</html>

调整大小的奇怪现象似乎是因为 mousemove 事件不会从 iframe 内冒泡而发生。只要浏览器能够跟上 mousemove 事件,使用调整大小处理程序和处理程序 CSS 中的大边框可以最大限度地减少 iframe 造成的影响。

关于jquery - 使用 jQuery UI 调整 iFrame 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1234144/

相关文章:

javascript - 在服务器响应之前检测 iframe 内容更改

javascript动态创建iframe,但是如何附加属性呢?

wpf - 如何从 WPF ListView 中删除多个选定项?

JavaFX 绘制形状时出现鼠标输入问题?

javascript - 未捕获的 TypeError :Cannot read property indexOf. 也许是 .load() jquery 问题?

javascript - 如何修复 Ajax 从数据库中获取任何内容?

javascript - 在我第一次调用它之前如何在 JS 中加载函数?

javascript - 无法将 Jquery 对象复制到 Jquery 对象中

javascript - 如何访问 FancyBox iframe 中的元素

iphone - 检查设备是否为 iPad