[英]Detect event on iframe
我的應用程序在 iframe 中打開..
$(window).scroll(function() { alert("scroll is");});
如果我在沒有 iframe 的情況下運行此代碼,它可以工作,但使用 iframe 則不起作用
以下是我包含在 iFrame 中的 HTML 文件的內容,Javascript 被正確調用。 也許將它與您所寫的進行比較。
<html>
<head>
<title>Test iFrame</title>
<!-- Add Some Space to Simulate Content (not needed) -->
<style>
body {
width: 100vh;
height: 100vh;
}
</style>
</head>
<body>
<p>iFrame content goes here</p>
<script type="text/javascript" src="jquery-3.1.1.min.js"></script>
<script>
// wait for jQuery to load
$(document).ready(function() {
$(window).scroll(function() {
alert("scroll is");
});
});
</script>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.