< object type =" text / html">< / object&gt ;?中的contents() [英] contents() in <object type="text/html"></object>?

查看:100
本文介绍了< object type =" text / html">< / object&gt ;?中的contents()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用

访问< iframe> 中加载的本地内容$(#frame)。contents()。find('div')。css(...)

$("#frame").contents().find('div').css(...)

使用时< object type =text / html> 而不是(相同的本地网站),内容功能不起作用。

When using a <object type="text/html"> instead (same local site), the contents function does not work.

还有其他方式还是我错过了什么?

Is there another way or did I miss something ?

以下是测试代码:

HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <link type="text/css" href="css/style.css" rel="stylesheet"/>
    <script type="text/javascript" src="js/jquery-1.3.2-min.js"></script>   
    <script type="text/javascript" src="js/try.js"></script>
</head>
<body>
    <div id="header"></div>
    <div id="here_goes_a_proprietary_side_i_dont_want_to_mess_inside">
        <object id="frame" type="text/html" data="/nastysite/index.php" width="100%" height="100%"></object>
    </div>
    <div id="footer"></div>
</body>

JS:

$(document).ready(function() {

    alert("go ?");  //temporary solution to wait until everything is loaded.
    $("#frame").contents().find('div').css("background-color", "red"); //nothing appens
    console.debug($("#frame").contents().find('div'));  //nothing
});


推荐答案

你的对象标签立即关闭,所以它没有孩子div找到。

Your object tag closes immediately, so it has no child div to find.

<object id="frame" type="text/html" data="/nastysite/index.php" width="100%" height="100%"></object>

这篇关于&lt; object type =&quot; text / html&quot;&gt;&lt; / object&gt ;?中的contents()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆