我尝试在stackoverflow中进行搜索。有关于这个问题的主题。我尝试了几个接近我的修复程序,但没有一个工作。我也试过谷歌搜索主题,但我尝试的任何东西都不起作用。
感谢任何帮助。
以下是这种情况,这个javascript确认有效,看到确认对话框出现并在Firefox中有效,但无法在IE或Chrome中运行,这意味着确认对话框没有出现,代码移动到相应的下一页如果确认:
function confirmReserve($checkin, $checkout, $nights, $points) {
var $in =new Date($checkin*1000);
var $out =new Date($checkout*1000);
if (confirm("Your Reservation Details: \n\nCheck-In Date: " + $in.toLocaleFormat('%B %d, %Y') + "\nCheck-Out Date: " + $out.toLocaleFormat('%B %d, %Y') + "\nTotal Nights: " + $nights + "\nTotal points: " + $points + "\n\nClick OK to process reservation.")) {
return true;
} else {
return false;
}
但是,这一个适用于所有三个:
function confirmDelete() {
if (confirm("Click OK to confirm cancellation of your reservation.")) {
return true;
} else {
return false;
}
}
它是相同的PHP程序,相同的浏览器。 以下是不起作用的HTML:
<form method="post" onsubmit="return confirmReserve('<?php echo $InDate;?>', '<?php echo $OutDate;?>', '<?php echo $totalNights;?>', '<?php echo $totalPoints;?>')" action="reservationConf.php">
以下是可行的HTML:
<form method="post" onsubmit="return confirmDelete()" action="deletereservation.php?ReservationID=' . $Reservation['ReservationID'] . '">
答案 0 :(得分:0)
尝试在您的函数之前放置以下代码:
var monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
Date.prototype.toLocaleFormat = Date.prototype.toLocaleFormat ||
function(pattern) {
return pattern.replace(/%Y/g, this.getFullYear())
.replace(/%m/g, (this.getMonth() + 1))
.replace(/%B/g, monthNames[this.getMonth()])
.replace(/%d/g, this.getDate());
};
根据JavaScript function not working on Chrome & IE but works on FireFox
,问题是Chrome和IE缺少LocaleFormat功能