我正试图让警告框显示元素名称(这里是html)(显然没有硬编码)触发事件onclick并按下ctrl键。
<!DOCTYPE html>
<html onclick="alertD(event)">
<head>
<title>
</title>
</head>
<body>
<!--<p>click anywhere on the page to display alert dialog</p>-->
<script type="text/javascript">
function alertD(event)
{
if (event.shiftKey)
{
alert(event);
}
else if(event.ctrlKey)
{
alert("html"); //-- this is where it would say something like alert(document.element)???
}
else
{
alert();
}
}