Home >Web Front-end >JS Tutorial >Right-clicking on a web page does not support event.preventDefault and event.returnValue (need to add window)_javascript skills

Right-clicking on a web page does not support event.preventDefault and event.returnValue (need to add window)_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:41:461318browse

The event.preventDefault() method is the default behavior for canceling events, but this method is not supported by IE. In IE, you need to use window.event.returnValue = false; to implement it.

Copy code The code is as follows:

function stopDefault( e )

{

if ( e && e.preventDefault ){ e.preventDefault();

} else { window.event.returnValue = false;

} }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn