简体   繁体   English

Javascript无法在Internet Explorer上运行

[英]Javascript not working on Internet Explorer

I am building a site for my first freelance client, he is having issues on Internet Explorer (barf) at his end when he tests it, I have tried on a Windows computer and the virtual machine on my Mac and in both cases it has worked. 我正在为我的第一个自由客户建立一个站点,他在测试Internet时遇到Internet Explorer(barf)的问题,我在Windows计算机和Mac上的虚拟机上都尝试过,并且在两种情况下都可以正常工作。

Here's what's meant to happen: 这是要发生的事情:

  1. User fills out the form 用户填写表格
  2. User clicks submit 用户点击提交
  3. Ajax validates using a php script Ajax使用php脚本进行验证
  4. If validation is ok - send emails with another php script, otherwise show error 如果验证正常-使用其他php脚本发送电子邮件,否则显示错误
  5. When validation succeeds and emails send, show a success message. 验证成功并发送电子邮件后,显示成功消息。

It all works as expected for me, but for the client the submit button doesn't do anything. 这一切对我来说都是预期的,但是对于客户端,“提交”按钮没有任何作用。

Also, on the FAQ page (2nd link in menu at top), clicking on a question has no effect whereas it should bring up an answer (as it does for me!). 另外,在“常见问题解答”页面(顶部菜单中的第二个链接)上,单击问题没有任何作用,而应该带来一个答案(对我来说是一样!)。

The site is here 该网站在这里

Why should it work on my version of IE and not his? 为什么它应该在我的IE版本而不是他的版本上起作用? Is it perhaps he has something blocking the Javascript? 也许他有一些阻止Javascript的东西? I'm at a loss with this, can anyone else reproduce the error or is it just him? 我对此感到茫然,其他任何人都可以重现该错误,还是仅仅是他?

It's worth mentioning that the site functions correctly on all other browsers. 值得一提的是,该网站可以在所有其他浏览器上正常运行。

Ok, I got it. 好,我知道了。 It does not work for me neither, until I open the IE Script Console (F12). 在我打开IE脚本控制台(F12)之前,它对我都不起作用。

So, the problem is that in your Javascript you used console.log('something') somewhere. 因此,问题在于在Javascript中,您在某处使用了console.log('something') Remeber to always remove calls to this method after you finish your debugging stuffs, because console is not defined in IE until the console is hidden (and it's always hidden on a non-dev computer). 你完成调试后,东西向Remeber 始终删除调用此方法,因为console是不是在IE中定义,直到控制台是隐藏的(它总是隐藏在非开发计算机上)。 The fact it's undefined, throws an error on log() method call that breaks your entire script. 它是未定义的事实,会在log()方法调用上引发错误,从而破坏整个脚本。

An alternate fix that worked for me is to patch in the console.log object with something like: 对我console.log的另一种解决方法是在console.log对象中打补丁,例如:

if ( !console ) var console = { log: function() { } };

then you can keep your console out messages for debugging purposes. 那么您可以将控制台信息排除在外,以进行调试。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM