javascript - 使用包含框架的 html 页面加载 Div

标签 javascript jquery html css

我想通过 javascript 在 div 中加载一个包含 2 个框架的 html 页面。 我在 div 中加载 html 资源的代码是

 Util.importResource("my_div_id", 'docs/admin/index.html');

加载div资源的函数。

Util={
importResource: function(divId, resourcePath, appender) {

    $("div#" + divId).load(resourcePath, function(resp, stat, req) {
        if(req.status <= 0 || req.status >= 400) {
            window.location.reload();
            return; 
        }
        if (typeof(appender) != "undefined" && appender != null)
        {
            resp += appender;
            $("div#" + divId).append(appender);
        }
    });
},

但该特定页面未显示在 div 中,其余纯 html 页面加载正常。 我的 Html 页面看起来像

<html>
<head>
    <title>asd</title>
</head>
<frameset cols="20%,*" style="border:0px solid #000000; background-color:#ffffff;"     frameborder="1">

    <frame name="toclist" title="content" src="toc.html" scrolling="auto"></frame>

    <frame name="bsscright" title="page" src="hr/title_page.html" scrolling="auto"></frame>

</frameset>
</html>

任何人都可以帮我解决这个问题吗?

最佳答案

我想你想追加 resp + appender

....
if (typeof(appender) != "undefined" && appender != null)
    {
        resp += appender;
        $("div#" + divId).append(resp );
    }
  else{
       $("div#" + divId).append(resp );
   }
.....

关于javascript - 使用包含框架的 html 页面加载 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12832534/

相关文章:

javascript - 16 :9 Aspect Ratio App & Background (Accounting for space taken by the Nav)

javascript - Extjs 子菜单在 Chrome 43 上消失

javascript - 无法在 React 组件中显示从获取的序列化 api 获取的信息

javascript - 无法将数据从 View 发布到 Yii2 中的 Controller

html - 在单页应用程序中将页脚设置为底部

javascript - CSS/JS 动态缩小? (表现)

JQuery 选择所有带有 style=background-color 的 p 标签

javascript - 在选择更改之前,如何使用 javascript 查找下拉列表所选选项的索引/值

html - R - 带有输入的网络抓取动态表单

javascript - 刷新页面后保持动态创建的复选框处于选中状态