0
我試圖建立對飛A HREF將它傳遞到的fancybox iframe和鏈路傳遞到一個PHP文件傳遞一個動態的href到的fancybox的iFrame
<script type="text/javascript">
jQuery(document).ready(function($){
$('a').each(function(){
var Href = 'GetImg.php?img=' + $(this).attr("href");
alert ("Href");
$(".Images").click(function() {
$.fancybox.open({
href : Href,
type : 'iframe',
padding : 5
});
});
};
}) ; // ready
</script>
HREF被設定即警報(」 Href「)並傳入php文件,但不在iframe中打開。 如果我硬代碼
href : 'GetImg.php?img=/images/myImg.jpg' it works
我的鏈接
<a class="Images" href="/images/myImg.jpg" title="A witty Title">Send to PHP</a>
FYI這是GetImg.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title>Holly Gibbons</title>
<script type="text/javascript" src="fancyBox-2.0.6/lib/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/ddpowerzoomer.js"></script>
<script type="text/javascript">
jQuery(function($){
$('#image3').addpowerzoom({
defaultpower: 2,
powerrange: [2,5],
largeimage: null,
magnifiersize: [100,100] //<--no comma following last option!
});
});
</script>
</head>
<body>
<?php
$my_img = $_GET['img'];
?>
<p> <img id="image3" src = <?php echo $my_img ?> /></p>
</body>
</html>
你好嗎確定選擇器'$('a> img')'? 'img'標籤似乎不在那裏(在'a'標籤內)。 –
不,這是一個錯字&我編輯 – Holly
而'alert(「Href」);'只是打印字符串'Href'。 –