将动态href传递到Fancybox iframe [英] Passing a dynamic href into Fancybox Iframe
本文介绍了将动态href传递到Fancybox iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试快速建立href,以将其传递到fancybox iframe并将链接传递到php文件中
I'm trying to build a href on the fly to pass it into fancybox iframe and pass the link into a php file
<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 is being set ie alert ("Href") and passed into the php file but isn't opening in the iframe. if i hard code
href : 'GetImg.php?img=/images/myImg.jpg' it works
我的链接是
<a class="Images" href="/images/myImg.jpg" title="A witty Title">Send to PHP</a>
仅供参考,这是GetImg.php
FYI This is the 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
标签并循环,您可以像
No need to select all a
tags and loop, you can do simply like
$(document).on('click', '.Images', function(e) {
e.preventDefault();
var Href = 'GetImg.php?img=' + $(this).attr("href");
alert(Href);
$.fancybox.open({
href: Href,
type: 'iframe',
padding: 5
});
});
这篇关于将动态href传递到Fancybox iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文