Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JqueryUi滑块不';我不能在iframe中工作_Jquery_Jquery Ui - Fatal编程技术网

JqueryUi滑块不';我不能在iframe中工作

JqueryUi滑块不';我不能在iframe中工作,jquery,jquery-ui,Jquery,Jquery Ui,我有以下建议: <!DOCTYPE html> <html> <head> </head> <body> <link rel="stylesheet" type="text/css" href="jquery-ui-1.9.2.custom.css"> <div id="slider"></div> </body> </html> 我有一页: <!DOCTYPE h

我有以下建议:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<link rel="stylesheet" type="text/css" href="jquery-ui-1.9.2.custom.css">
<div id="slider"></div>
</body>
</html>

我有一页:

<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script src="jquery-ui-1.9.2.custom.js"></script>
<title></title>
</head>
<body>
<iframe id="frame" src="iframe.html" width="800" ></iframe>
<script type="text/javascript">
$(document).ready(function() {
    $('#frame').contents().find('#slider').slider({
        value:2,
        min: 0,
        max: 6,
        step: 1,
        animate: true,
        slide: function( event, ui ) {
        }
    });
});
</script>
</body>
</html>

$(文档).ready(函数(){
$('#frame').contents().find('#slider').slider({
价值:2,
分:0,,
最高:6,
步骤:1,
动画:对,
幻灯片:功能(事件、用户界面){
}
});
});
我只是想在iframe自定义滑块,但这是不工作,我不知道为什么。这件作品完美无瑕


更新:通过调用从iframe创建slider的函数修复此问题。由于安全原因,iframe是一个单独的html页面(不同的文档),无法访问父脚本等

您需要在iframe html文档中包含jQuery和jqueryui,并在该文档中运行该函数

下面是一篇关于原因的综合文章:

更新。我有未捕获的引用错误:jQuery没有定义jQuery-ui-1.9.2.custom.js:351(匿名函数)有些东西告诉我你不能从父页面实例化一个滑块,但是你必须在iframe中进行实例化。但是原因是什么?你需要从框架调用它,出于安全原因,但我现在试图申报,但没有用