Solution to the error "event is not defined" prompt in Firefox

Source: Internet
Author: User

First, let's look at a piece of html code:

<Html> 

The above js code means that if you click Enter on the current page, a warning box will pop up, showing the warning content. This is not the focus.

This code runs normally in IE, but the error "event is not defined" will be reported in Firefox! Firefox reported this error because the event object model used in Firefox is W3C Dom, which is different from IE Dom. There is no event in Firefox DOM, because Firefox cannot get the event object through window. event. How can this problem be solved?

After multiple tests, the solution is as follows, which can be compatible with event Events of IE and Firefox at the same time. Slightly process the above js Code.

document.onkeydown=function mykeyDown(e){e=e||event;if(e.keyCode==13){alert('oh my www.phpernote.com');}return;}

OK. Now, the Firefox prompts that the event is not defined error is resolved.

Articles you may be interested in
  • Php prompts PHP Warning: date (): It is not safe to rely on the... solution to the error
  • Php prompts Call to undefined function curl_init () Error Solution
  • Select into from prompt Undeclared variable... solution to the error
  • Fatal error Class 'soapclient' not found in... troubleshooting method
  • Solution to the DedeTag Engine Create File False error in dedeCMS
  • Php prompts Maximum execution time of 30 seconds exceeded... solution to the error
  • How to solve the Call to undefined function curl_init error in php running?
  • The progress bar of XDebug stops at 57%, prompting you to solve the waiting for XDebug session error.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.