【问题标题】:iFrame within JQuery Dialog loads up empty in Firefox and chromeJQuery Dialog 中的 iFrame 在 Firefox 和 chrome 中加载为空
【发布时间】:2011-11-15 20:46:20
【问题描述】:

以下页面在 JQuery 对话框中显示了一个 iFrame。这是一个完整的工作页面,您可能只需要修复顶部的 jQuery 和样式表引用。我在 Visual Studio 的 ASP.NET MVC3 项目中创建它...

<!DOCTYPE html>
<html>
<head>
    <title>Dialog Test</title>
    <link href="../../Content/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-ui-1.8.11.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function showDialog() {
            $("#divId").dialog({
                title: 'Test Dialog',
                resizable: false,
                modal: false,
                height: 500,
                width: 500
            });

            $("#myFrame").attr("src", "http://www.google.com");
            return false;
        }
    </script>
</head>
<body>
    <a href="" onclick="return showDialog();">Show Dialog</a>
    <div id="divId" style="display: none;">
        <iframe id="myFrame" name="myFrame" width="100%" height="100%" frameborder="1" scrolling="auto" />
    </div>
</body>
</html>

此代码在 Internet Explorer 中运行没有问题,但在 Chrome 和 FireFox 中无法运行。 iFrame 加载,但它只是空的。请帮忙。我将不胜感激任何提示/建议。

【问题讨论】:

    标签: jquery firefox google-chrome iframe dialog


    【解决方案1】:

    试试这个:

    function showDialog() {
     ("#divId").dialog({
     //...
     })
    
     $("#divId").html('<iframe id="myFrame"  src="http://www.google.com" name="myFrame" width="100%" height="100%" frameborder="1" scrolling="auto" />')
    return false;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-29
      • 2012-11-03
      • 2011-09-26
      • 2017-09-29
      • 2011-05-31
      • 2012-11-09
      • 1970-01-01
      相关资源
      最近更新 更多