1
我試圖從iframe調用colorbox close()函數。這是我的。從iframe調用colorbox關閉
首頁
<script>
$(document).ready(function(){
$("#click").colorbox({width:"60%",
height:"60%",
iframe:true
});
});
</script>
<a href="login.html" id="click">Click Me!</a>
的login.html
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="jquery.colorbox.js"></script>
<script>
$(document).ready(function(){
setTimeout(function() {
parent.jQuery.fn.colorbox.close();
}, 3000);
});
</script>
</head><body></body>
</html>
時的setTimeout被稱爲我得到這個錯誤。
Uncaught TypeError: Cannot read property 'fn' of undefined
我試圖按照這個線程中的答案。 how to close colorbox within iframe?
嘗試刪除'.fn'只有'parent.jQuery.colorbox.close();' – 2013-03-19 17:26:57
'不能讀的未定義的屬性顏色框' – RKodakandla 2013-03-19 17:31:29
你有沒有參考'colorbox'腳本...? – Dom 2013-03-19 19:41:45