0
基本上,我有2個php頁面,這是a.php和b.php。我想要實現的是將一個jquery函數綁定到b.php的內容中。綁定到iframe中的內容控制
jquery函數將用於觸發a.php中的彈出窗口。但是,我無法得到它的工作。有人知道我做了什麼錯誤嗎?
a.php只會
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script>
$(function() {
var abc = function(){
alert("");
}
$("iframe").contents().find("a.toggle").click(abc);
});
</script>
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
</head>
<body>
<form method="post" action="">
<div class="container" id="">
<div class="resize main" id="" style="height: 600px;">
<iframe id="" frameborder="0" scrolling="no" src="b.php" style="width: 1022px; border: none; height: 600px;">
</iframe>
</div>
</div>
</form>
</body>
</html>
b.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
</head>
<body>
<form method="post" action="b.php">
<div class="titlewrap">
<div id="" class="pagetitle">
<a class="toggle" href="#"><span class="icon slider-close">aa</span></a>
</div>
</div>
</form>
</body>
</html>
看看這個:http://stackoverflow.com/questions/1655862/attach-click-handler-even-on-element-inside-iframe-with -jquery。另外你的問題與PHP無關。 –