我在脚本确认方面遇到了一些问题。按照标准,它设置为隐藏联系表单并显示确认消息,但它不适用于所有浏览器。经过一些测试后,我意识到它不适用于大多数 IE 版本,这些版本约占我访问者的 40%。
如何将 hide-and-show-msg 替换为“thankyou.html”?我猜这是可行的,因为大多数 IE 无法显示确认消息,尽管它们设法隐藏了表单。 “header”中的代码目前是:
<script src="php/js/jquery.validate.js"></script>
<script src="php/js/jquery.placeholder.js"></script>
<script src="php/js/jquery.form.js"></script>
<script>
$(function(){
$('#contact').validate({
submitHandler: function(form) {
$(form).ajaxSubmit({
url: 'thankyou.php',
success: function() {
$('#contact').hide();
$('#contact-form').append("<p class='thanks'>Thank you! The message was sent.</center></p>")
}
});
}
});
});
</script>
最佳答案
已解决。
我添加了一个条件脚本
<head>
<!--[if IE]>
<script >
document.createElement("section");
</script >
<![endif]-->
http://plungjan.name/test/testform_validation.html
您需要做的是附加到 IE 可以理解的元素。
如果您不需要条件脚本,请在页面末尾添加一个 div 并附加到该页面,而不是像这里:http://plungjan.name/test/testformvalidation.html
其他问题:我得到了
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.1)
Timestamp: Tue, 17 May 2011 13:15:29 UTC
Message: Unexpected call to method or property access.
Line: 5569
Char: 5
Code: 0
URI: http://code.jquery.com/jquery-1.6.1.js
finally 好像不支持
当我在 finally 之前添加 catch(e) {}
时 - 错误消失了
resolveWith: function( context, args ) {
if ( !cancelled && !fired && !firing ) {
// make sure args are available (#8421)
args = args || [];
firing = 1;
try {
while( callbacks[ 0 ] ) {
callbacks.shift().apply( context, args );
}
}
catch(e) { /* ADDED BY ME */ }
finally {
fired = [ context, args ];
firing = 0;
}
}
return this;
},
关于php - HTML5 php 联系表单脚本确认,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6030727/