需要有人在the jQuery Dialog plugin by Eric Martin - Simple Model
帮助我我有一个PHP页面,其中包含我想将值传递给另一个页面的链接。因此,我需要有关如何将值传递给包含下面页面URL的var的jQuery脚本的帮助?
Profile.php
<div id='basic-modal'>
<a href='#' class='basic'>Jquery Dialog Demo</a>
</div>
注意:当我点击链接时,它将从Basic.js调用jQuery基本模型div
Basic.js
jQuery(function ($) {
// Load dialog on click
$('#basic-modal .basic').click(function (e) {
// Display an external page using an iframe
var src = "http://365.ericmmartin.com/";
$.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
closeHTML:"",
containerCss:{
backgroundColor:"#fff",
borderColor:"#fff",
height:450,
padding:0,
width:830
},
overlayClose:true
});
return false;
});
});
注意:在上面,我希望var src包含我的变量值 应该从Profile.php传递它。我该怎么做?
答案 0 :(得分:2)
稍微更改Profile.php:
<div id='basic-modal'>
<a href='http://localhost/Poll.php?id=1&validate=yes' class='basic'>Jquery Dialog Demo</a>
</div>
像这样更改Basic.js:
jQuery(function ($) {
// Load dialog on click
$('#basic-modal .basic').click(function (e) {
e.preventDefault();
// Display an external page using an iframe
var src = $(this).attr('href');
$.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
closeHTML:"",
containerCss:{
backgroundColor:"#fff",
borderColor:"#fff",
height:450,
padding:0,
width:830
},
overlayClose:true
});
return false; // not sure why you're doing this
}); // end of click handler
}); // end of document.ready
答案 1 :(得分:1)
e.preventDefault();
var src = $(e.target).attr("href");