2013-11-27 46 views
0

這是不行的...爲什麼?在iframe中用jquery查找對象

從[http://api.jquery.com/contents/]

<!doctype html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <title>contents demo</title> 
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
</head> 
<body> 

<iframe src="http://api.jquery.com/" width="80%" height="600" id="frameDemo"></iframe> 

<script> 
$("#frameDemo").contents().find("a").css("background-color", "#BADA55"); 
</script> 

</body> 
</html> 

我試圖像這樣

警報($( 「#frameDemo」).contents()。找到(「.constrain」).html());

它現在工作太...

請幫助我。

+0

您沒有訪問該IFRAME任何由於交叉同源策略,因爲它不是在同一個域作爲當前頁面 – adeneo

回答