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.