开发者

contents() in <object type="text/html"></object>?

I can access local contents loaded in an <iframe> with

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

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 ?

Here follows the test code:

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&开发者_JAVA百科gt;
<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
});


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜