简体   繁体   中英

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.

Here's what's meant to happen:

  1. User fills out the form
  2. User clicks submit
  3. Ajax validates using a php script
  4. If validation is ok - send emails with another php script, otherwise show error
  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? Is it perhaps he has something blocking the 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).

So, the problem is that in your Javascript you used console.log('something') somewhere. 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). The fact it's undefined, throws an error on log() method call that breaks your entire script.

An alternate fix that worked for me is to patch in the console.log object with something like:

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

then you can keep your console out messages for debugging purposes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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