jquery - 在 iframe 区域外拖动(移动)jquery ui 对话框

标签 jquery html iframe

我已经在 iframe 中打开了 jquery 可拖动对话框。它在 iframe 中工作正常,但我无法将 jquery 对话框拖到 iframe 之外。我想将对话框拖到 iframe 之外。有人知道我该怎么做吗?

下面是我在 movable.php 文件中使用的示例代码。

<html>
<head>
<link href="http://www.jquerydemo.dailyfreecode.com/Styles/Site.css" rel="stylesheet" type="text/css" />
<link href="http://www.jquerydemo.dailyfreecode.com/Styles/css/sunny/jquery-ui-1.8.22.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js"></script>
<style>
.ui-dialog
{
position:relative !important;
top:0px !important;
}
</style>
</head>
<body>
<a id="hlOpenMe" href="#">Click Me to Open Dialog Box</a>
<div id="dialog" title="My Dialog Title">
<p>This is My Dialog box Description/Content</p>
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#dialog").dialog({ autoOpen: false });

$("#hlOpenMe").click(
function () {
$("#dialog").dialog('open');
return false;
}
);
});
</script>
</body>

现在我在 demo.php 页面中调用了 iframe。

<iframe src="movable.php" id="name" name="test" width="50%" height="50%">
</iframe>

最佳答案

你不能这样做。对于您的脚本,浏览器窗口是调用它的 iFrame。 jQuery 不知道 iFrame 的存在和“外部”。

关于jquery - 在 iframe 区域外拖动(移动)jquery ui 对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15110444/

相关文章:

javascript - 为什么在使用 bootstrap 时,动态生成的表单字段没有边距?

javascript - 'el' 在 vi​​ew.render().el 中做了什么?

javascript - 如何验证从浏览器中运行的 JS 生成的 html?

php - 单击元素后显示元素详细信息

iframe - SimpleModal - 使用关闭按钮关闭 iframe

javascript - 根据数据值向单元格添加类

javascript - jquery 显示无不工作

javascript - 我的文本框 html 代码有什么问题?

javascript - 未捕获的安全错误 : Failed to read the 'contentDocument' property from 'HTMLIFrameElement'

javascript - 如何 "spoof"小 iframe 的宽度,以便内容显示为桌面而不是遵循移动媒体查询?