简体   繁体   English

JavaScript 在 Safari 中不起作用,但在 Firefox 和 Chrome 中起作用

[英]JavaScript doesn't work in Safari but does in Firefox and Chrome

I have a form that I am validating with Parsley.我有一个表格,我正在用 Parsley 进行验证。 The submit button has the following JavaScript code in order to animate via css.提交按钮具有以下 JavaScript 代码,以便通过 css 进行动画处理。 This works perfectly in Firefox and Chrome but in Safari (desktop and iOS) is does nothing.这在 Firefox 和 Chrome 中完美运行,但在 Safari(桌面和 iOS)中不起作用。 The form validates just fine but the animation doesn't run.表单验证正常,但动画不运行。

I tracked it down to the return true;我追踪到返回 true; statement.陈述。 If I set it to return false;如果我将其设置为返回 false; Safari works as it should, except that the form does not submit. Safari 正常工作,只是表单不提交。 If I set it to return true;如果我将其设置为返回 true; it works everywhere I've tested except for Safari.它适用于我测试过的所有地方,除了 Safari。

I've read a bunch of docs about how Safari works differently with jQuery and thus the JS code has to be modified in order to for it to truly be cross browser.我已经阅读了一堆关于 Safari 如何与 jQuery 不同的文档,因此必须修改 JS 代码才能使其真正跨浏览器。 How can I modify this to work everywhere?如何修改它以在任何地方工作?

 <script type="text/javascript"> $(function() { $('#login-form').parsley().on('form:submit', function() { $(".loginbutton").addClass("loginactive"); $(".loginbutton").css("background", "transparent"); setTimeout(function() { $(".loginbutton").addClass("loginsuccess"); $(".loginbutton").css("background", "none repeat scroll 0 0 #ffffff"); }, 3700); return true; }); }); </script>

The answer is that Safari will cease all animation on another object loading (python script, another url, etc.) and there's basically nothing you can do about it.答案是 Safari 将停止加载另一个对象(python 脚本、另一个 url 等)时的所有动画,并且您基本上无能为力。 It will only show the first frame of the css animation.它只会显示 css 动画的第一帧。 So, what I did was modify the login button to look different a show logging in when the form is being submitted.所以,我所做的是修改登录按钮,使其看起来与提交表单时显示登录不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Javascript窗口调整大小在Safari中不起作用,但在Firefox中起作用 - Javascript window resize doesn't work in Safari but does in Firefox Javascript函数不适用于Firefox,但适用于Chrome,Safari,IE和Edge - Javascript function does not work in firefox but does in chrome, safari, IE and edge jsPDF在Chrome中不起作用,只适用于Firefox和Safari - jsPDF doesn't work in Chrome, only Firefox & Safari 我的视频实现无法在Firefox和Safari浏览器中使用; 仅镀铬 - My implementation of video doesn't work in firefox and safari; only chrome Firefox Javascript div旋转不起作用,但在Chrome和Safari中可以正常工作 - Firefox Javascript div rotation not working, but does work in Chrome and Safari 尝试建立会计计算器,但JavaScript在Safari / Firefox中不起作用 - Trying to build accountants calculators but javascript doesn't work on safari/firefox JavaScript回调可在Firefox中使用,但不能在Chrome或Safari中使用 - Javascript callbacks work in Firefox but not in Chrome or Safari 在php文件中创建javascript代码-SAFARI / CHROME不起作用 - create javascript code in a php file - SAFARI/CHROME doesn't work 为什么JavaScript不适用于Firefox / Chrome但适用于IE? - Why doesn't the JavaScript work for Firefox/Chrome but for IE? 该Javascript在IE中不起作用,但在Chrome,Firefox和Opera中起作用 - This Javascript doesn't work in IE but works in Chrome, Firefox and Opera
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM