<! DOCTYPE html > conflicts with onmousedown because event is not valid. Why is this so? How to modify it?

onmousedown is used in the body tag to listen for mouse events, but the events have no effect at all. Baidu later said that made event invalid. It is said that it is because of the width problem, but it has not worked yet. If you remove , you can use

.

the code is as follows:

<!DOCTYPE html>
<html>
  <head>
    <title>objecjs20.html</title>
    <script language="javascript" type="text/javascript">
    <!--
        function show_coords(e){
        x=e.clientX;
        y=e.clientY;
        alert(e+"--X :"+x+",Y :"+y);
        }
    //-->
    </script>
  </head>
  <body onmousedown="show_coords(e)">
  <div height="100%" width="100%">fdjl</div>
  </body>
</html>
Mar.04,2021

judge whether there is,

function show_coords(e){
var _event = e || event
......
}

1, document mode
when there is no document mode, you are in mixed mode, and html and body will fill the full screen.
turns on standard mode, where html and body have no height by default.
this can be set at this time.

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

2, incoming event
if you want to pass in an event in the html tag, you should use event instead of e.

<body onmousedown="show_coords(event)">
Menu