实际上,问题在于您的其余代码。为你让我挖掘它而感到羞耻。:P
$('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
// etc etc.
因此,您会因为 preventDefault 而阻止 href 触发。为什么不在这里打补丁:
$('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
if ($(window).width() < 767)
{
// I'm assuming you'd get this dynamically somehow;
location.href="https://secured.sirvoy.com/book.php?c_id=1602&h=ea3a7c9286f068fb6c1462fad233a5e0";
return;
}
// etc etc.
已添加 | 帮助 OP 使他的项目工作的功能全文:
$('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
if ($(window).width() < 767)
{
// I'm assuming you'd get this dynamically somehow;
location.href="https://secured.sirvoy.com/book.php?c_id=1602&h=ea3a7c9286f068fb6c1462fad233a5e0";
return;
}
//Get the A tag
var id = $(this).attr('href');
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set height and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//transition effect
$(id).fadeIn(2000);
});