下面的例子检查鼠标是否在链接上单击,并且,如果shift键被按下,就取消链接的跳转。 <HTML> 
<HEAD><TITLE>Cancels Links</TITLE> 
<SCRIPT LANGUAGE="JScript"> 
function cancelLink() { 
if (window.event.srcElement.tagName == "A" && window.event.shiftKey) 
window.event.returnValue = false; 

</SCRIPT> 
<BODY onclick="cancelLink()"> 
<a href=#>8080</a>

解决方案 »

  1.   

    <HTML> 
    <HEAD><TITLE>Cancels Links</TITLE> 
    <BODY onclick="cancelLink()"> 
    <SCRIPT LANGUAGE="JScript"> 
    function cancelLink() { 
    var tag;
    tag=window.event.srcElement.tagName;
    window.status=tag;

    </SCRIPT> 
      

  2.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>New Page 1</title>
    <script language="javascript">
    function tagInfo()
    {
    var tag;
    tag=window.event.srcElement.tagName;
    window.status=tag;
    }</script>
    </head><body onclick="tagInfo()">
    <h1 id="head1">head1 one</h1>
    <p>more text ans some<b>bold font</b>text</p>
    </body>   
       
    </html>   触发事件变成click
      

  3.   

    tag=window.event.srcElement.tagName;改成tag=window.event.srcElement;试试呢?
      

  4.   

    to:TXZY(木下藤吉郎)
    这样不行啊,虽然网页不会抱错,可是window.status的值变为null了
      

  5.   

    event.srcElement is not available when onload event is triggered
      

  6.   

    不知道这是不是你想要的
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>New Page 1</title>
    <script language="javascript">
    function tagInfo()
    {
    var tag;
    tag=window.youname.tagName;
    window.status=tag;
    }
    </script>
    </head>
    <body onLoad="tagInfo()">
    <h1 id="head1">head1 one</h1>
    <p>more text ans some<b>bold font</b>text</p>
    <input type=button id=youname value=jjjjjjj>
    </body>   
    </html>
      

  7.   

    agree karma(无为)!
    因为你不是通过链接打开的此文件,而是直接打开的此文件。
    所以你所取得的window.event.srcElement是空值。当然就更不会存在tagName这个属性了。